diff --git a/IPython/utils/path.py b/IPython/utils/path.py index 1d2c9e8..cca7a8e 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -77,7 +77,8 @@ def unquote_filename(name, win32=(sys.platform=='win32')): This function has been deprecated and should not be used any more: unquoting is now taken care of by :func:`IPython.utils.process.arg_split`. """ - warn("'unquote_filename' is deprecated", DeprecationWarning) + warn("'unquote_filename' is deprecated since IPython 5.0 and should not " + "be used anymore", DeprecationWarning) if win32: if name.startswith(("'", '"')) and name.endswith(("'", '"')): name = name[1:-1] @@ -98,18 +99,13 @@ def get_py_filename(name, force_win32=None): If the given name is not a file, it adds '.py' and searches again. Raises IOError with an informative message if the file isn't found. - - On Windows, apply Windows semantics to the filename. In particular, remove - any quoting that has been applied to it. This option can be forced for - testing purposes. """ name = os.path.expanduser(name) - if force_win32 is None: - win32 = (sys.platform == 'win32') - else: - win32 = force_win32 - name = unquote_filename(name, win32=win32) + if force_win32 is not None: + warn("The 'force_win32' argument to 'get_py_filename' is deprecated " + "since IPython 5.0 and should not be used anymore", + DeprecationWarning) if not os.path.isfile(name) and not name.endswith('.py'): name += '.py' if os.path.isfile(name): diff --git a/IPython/utils/tests/test_path.py b/IPython/utils/tests/test_path.py index 2378e51..4aba13f 100644 --- a/IPython/utils/tests/test_path.py +++ b/IPython/utils/tests/test_path.py @@ -305,25 +305,20 @@ def test_not_writable_ipdir(): @with_environment def test_get_py_filename(): os.chdir(TMP_TEST_DIR) - for win32 in (True, False): - with make_tempfile('foo.py'): - nt.assert_equal(path.get_py_filename('foo.py', force_win32=win32), 'foo.py') - nt.assert_equal(path.get_py_filename('foo', force_win32=win32), 'foo.py') - with make_tempfile('foo'): - nt.assert_equal(path.get_py_filename('foo', force_win32=win32), 'foo') - nt.assert_raises(IOError, path.get_py_filename, 'foo.py', force_win32=win32) - nt.assert_raises(IOError, path.get_py_filename, 'foo', force_win32=win32) - nt.assert_raises(IOError, path.get_py_filename, 'foo.py', force_win32=win32) - true_fn = 'foo with spaces.py' - with make_tempfile(true_fn): - nt.assert_equal(path.get_py_filename('foo with spaces', force_win32=win32), true_fn) - nt.assert_equal(path.get_py_filename('foo with spaces.py', force_win32=win32), true_fn) - if win32: - nt.assert_equal(path.get_py_filename('"foo with spaces.py"', force_win32=True), true_fn) - nt.assert_equal(path.get_py_filename("'foo with spaces.py'", force_win32=True), true_fn) - else: - nt.assert_raises(IOError, path.get_py_filename, '"foo with spaces.py"', force_win32=False) - nt.assert_raises(IOError, path.get_py_filename, "'foo with spaces.py'", force_win32=False) + with make_tempfile('foo.py'): + nt.assert_equal(path.get_py_filename('foo.py'), 'foo.py') + nt.assert_equal(path.get_py_filename('foo'), 'foo.py') + with make_tempfile('foo'): + nt.assert_equal(path.get_py_filename('foo'), 'foo') + nt.assert_raises(IOError, path.get_py_filename, 'foo.py') + nt.assert_raises(IOError, path.get_py_filename, 'foo') + nt.assert_raises(IOError, path.get_py_filename, 'foo.py') + true_fn = 'foo with spaces.py' + with make_tempfile(true_fn): + nt.assert_equal(path.get_py_filename('foo with spaces'), true_fn) + nt.assert_equal(path.get_py_filename('foo with spaces.py'), true_fn) + nt.assert_raises(IOError, path.get_py_filename, '"foo with spaces.py"') + nt.assert_raises(IOError, path.get_py_filename, "'foo with spaces.py'") @onlyif_unicode_paths def test_unicode_in_filename():