From a524414a9e838c235623b02303ecb8f00ecaf926 2021-10-23 12:01:15 From: Samuel Gaist Date: 2021-10-23 12:01:15 Subject: [PATCH] [core][tests][paths] Remove nose --- diff --git a/IPython/core/tests/test_paths.py b/IPython/core/tests/test_paths.py index 2182cb7..e5de945 100644 --- a/IPython/core/tests/test_paths.py +++ b/IPython/core/tests/test_paths.py @@ -6,7 +6,6 @@ import tempfile import warnings from unittest.mock import patch -import nose.tools as nt from testpath import modified_env, assert_isdir, assert_isfile from IPython import paths @@ -52,7 +51,7 @@ def test_get_ipython_dir_1(): modified_env({'IPYTHONDIR': env_ipdir}): ipdir = paths.get_ipython_dir() - nt.assert_equal(ipdir, env_ipdir) + assert ipdir == env_ipdir def test_get_ipython_dir_2(): """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions.""" @@ -66,7 +65,7 @@ def test_get_ipython_dir_2(): }): ipdir = paths.get_ipython_dir() - nt.assert_equal(ipdir, os.path.join("someplace", ".ipython")) + assert ipdir == os.path.join("someplace", ".ipython") def test_get_ipython_dir_3(): """test_get_ipython_dir_3, move XDG if defined, and .ipython doesn't exist.""" @@ -81,10 +80,10 @@ def test_get_ipython_dir_3(): }), warnings.catch_warnings(record=True) as w: ipdir = paths.get_ipython_dir() - nt.assert_equal(ipdir, os.path.join(tmphome.name, ".ipython")) + assert ipdir == os.path.join(tmphome.name, ".ipython") if sys.platform != 'darwin': - nt.assert_equal(len(w), 1) - nt.assert_in('Moving', str(w[0])) + assert len(w) == 1 + assert "Moving" in str(w[0]) finally: tmphome.cleanup() @@ -106,10 +105,11 @@ def test_get_ipython_dir_4(): }), warnings.catch_warnings(record=True) as w: ipdir = paths.get_ipython_dir() - nt.assert_equal(ipdir, os.path.join(HOME_TEST_DIR, ".ipython")) + assert ipdir == os.path.join(HOME_TEST_DIR, ".ipython") if sys.platform != 'darwin': - nt.assert_equal(len(w), 1) - nt.assert_in('Ignoring', str(w[0])) + assert len(w) == 1 + assert "Ignoring" in str(w[0]) + def test_get_ipython_dir_5(): """test_get_ipython_dir_5, use .ipython if exists and XDG defined, but doesn't exist.""" @@ -128,7 +128,7 @@ def test_get_ipython_dir_5(): }): ipdir = paths.get_ipython_dir() - nt.assert_equal(ipdir, IP_TEST_DIR) + assert ipdir == IP_TEST_DIR def test_get_ipython_dir_6(): """test_get_ipython_dir_6, use home over XDG if defined and neither exist.""" @@ -146,8 +146,8 @@ def test_get_ipython_dir_6(): }), warnings.catch_warnings(record=True) as w: ipdir = paths.get_ipython_dir() - nt.assert_equal(ipdir, os.path.join(HOME_TEST_DIR, '.ipython')) - nt.assert_equal(len(w), 0) + assert ipdir == os.path.join(HOME_TEST_DIR, ".ipython") + assert len(w) == 0 def test_get_ipython_dir_7(): """test_get_ipython_dir_7, test home directory expansion on IPYTHONDIR""" @@ -155,7 +155,8 @@ def test_get_ipython_dir_7(): with modified_env({'IPYTHONDIR': os.path.join('~', 'somewhere')}), \ patch.object(paths, '_writable_dir', return_value=True): ipdir = paths.get_ipython_dir() - nt.assert_equal(ipdir, os.path.join(home_dir, 'somewhere')) + assert ipdir == os.path.join(home_dir, "somewhere") + @skip_win32 def test_get_ipython_dir_8(): @@ -164,14 +165,16 @@ def test_get_ipython_dir_8(): # test only when HOME directory actually writable return - with patch.object(paths, '_writable_dir', lambda path: bool(path)), \ - patch.object(paths, 'get_xdg_dir', return_value=None), \ - modified_env({ - 'IPYTHON_DIR': None, - 'IPYTHONDIR': None, - 'HOME': '/', - }): - nt.assert_equal(paths.get_ipython_dir(), '/.ipython') + with patch.object(paths, "_writable_dir", lambda path: bool(path)), patch.object( + paths, "get_xdg_dir", return_value=None + ), modified_env( + { + "IPYTHON_DIR": None, + "IPYTHONDIR": None, + "HOME": "/", + } + ): + assert paths.get_ipython_dir() == "/.ipython" def test_get_ipython_cache_dir(): @@ -181,18 +184,16 @@ def test_get_ipython_cache_dir(): os.makedirs(os.path.join(HOME_TEST_DIR, ".cache")) with modified_env({'XDG_CACHE_HOME': None}): ipdir = paths.get_ipython_cache_dir() - nt.assert_equal(os.path.join(HOME_TEST_DIR, ".cache", "ipython"), - ipdir) + assert os.path.join(HOME_TEST_DIR, ".cache", "ipython") == ipdir assert_isdir(ipdir) # test env override with modified_env({"XDG_CACHE_HOME": XDG_CACHE_DIR}): ipdir = paths.get_ipython_cache_dir() assert_isdir(ipdir) - nt.assert_equal(ipdir, os.path.join(XDG_CACHE_DIR, "ipython")) + assert ipdir == os.path.join(XDG_CACHE_DIR, "ipython") else: - nt.assert_equal(paths.get_ipython_cache_dir(), - paths.get_ipython_dir()) + assert paths.get_ipython_cache_dir() == paths.get_ipython_dir() def test_get_ipython_package_dir(): ipdir = paths.get_ipython_package_dir()