##// END OF EJS Templates
[core][tests][paths] Remove nose
Samuel Gaist -
Show More
@@ -6,7 +6,6 b' import tempfile'
6 6 import warnings
7 7 from unittest.mock import patch
8 8
9 import nose.tools as nt
10 9 from testpath import modified_env, assert_isdir, assert_isfile
11 10
12 11 from IPython import paths
@@ -52,7 +51,7 b' def test_get_ipython_dir_1():'
52 51 modified_env({'IPYTHONDIR': env_ipdir}):
53 52 ipdir = paths.get_ipython_dir()
54 53
55 nt.assert_equal(ipdir, env_ipdir)
54 assert ipdir == env_ipdir
56 55
57 56 def test_get_ipython_dir_2():
58 57 """test_get_ipython_dir_2, Testcase to see if we can call get_ipython_dir without Exceptions."""
@@ -66,7 +65,7 b' def test_get_ipython_dir_2():'
66 65 }):
67 66 ipdir = paths.get_ipython_dir()
68 67
69 nt.assert_equal(ipdir, os.path.join("someplace", ".ipython"))
68 assert ipdir == os.path.join("someplace", ".ipython")
70 69
71 70 def test_get_ipython_dir_3():
72 71 """test_get_ipython_dir_3, move XDG if defined, and .ipython doesn't exist."""
@@ -81,10 +80,10 b' def test_get_ipython_dir_3():'
81 80 }), warnings.catch_warnings(record=True) as w:
82 81 ipdir = paths.get_ipython_dir()
83 82
84 nt.assert_equal(ipdir, os.path.join(tmphome.name, ".ipython"))
83 assert ipdir == os.path.join(tmphome.name, ".ipython")
85 84 if sys.platform != 'darwin':
86 nt.assert_equal(len(w), 1)
87 nt.assert_in('Moving', str(w[0]))
85 assert len(w) == 1
86 assert "Moving" in str(w[0])
88 87 finally:
89 88 tmphome.cleanup()
90 89
@@ -106,10 +105,11 b' def test_get_ipython_dir_4():'
106 105 }), warnings.catch_warnings(record=True) as w:
107 106 ipdir = paths.get_ipython_dir()
108 107
109 nt.assert_equal(ipdir, os.path.join(HOME_TEST_DIR, ".ipython"))
108 assert ipdir == os.path.join(HOME_TEST_DIR, ".ipython")
110 109 if sys.platform != 'darwin':
111 nt.assert_equal(len(w), 1)
112 nt.assert_in('Ignoring', str(w[0]))
110 assert len(w) == 1
111 assert "Ignoring" in str(w[0])
112
113 113
114 114 def test_get_ipython_dir_5():
115 115 """test_get_ipython_dir_5, use .ipython if exists and XDG defined, but doesn't exist."""
@@ -128,7 +128,7 b' def test_get_ipython_dir_5():'
128 128 }):
129 129 ipdir = paths.get_ipython_dir()
130 130
131 nt.assert_equal(ipdir, IP_TEST_DIR)
131 assert ipdir == IP_TEST_DIR
132 132
133 133 def test_get_ipython_dir_6():
134 134 """test_get_ipython_dir_6, use home over XDG if defined and neither exist."""
@@ -146,8 +146,8 b' def test_get_ipython_dir_6():'
146 146 }), warnings.catch_warnings(record=True) as w:
147 147 ipdir = paths.get_ipython_dir()
148 148
149 nt.assert_equal(ipdir, os.path.join(HOME_TEST_DIR, '.ipython'))
150 nt.assert_equal(len(w), 0)
149 assert ipdir == os.path.join(HOME_TEST_DIR, ".ipython")
150 assert len(w) == 0
151 151
152 152 def test_get_ipython_dir_7():
153 153 """test_get_ipython_dir_7, test home directory expansion on IPYTHONDIR"""
@@ -155,7 +155,8 b' def test_get_ipython_dir_7():'
155 155 with modified_env({'IPYTHONDIR': os.path.join('~', 'somewhere')}), \
156 156 patch.object(paths, '_writable_dir', return_value=True):
157 157 ipdir = paths.get_ipython_dir()
158 nt.assert_equal(ipdir, os.path.join(home_dir, 'somewhere'))
158 assert ipdir == os.path.join(home_dir, "somewhere")
159
159 160
160 161 @skip_win32
161 162 def test_get_ipython_dir_8():
@@ -164,14 +165,16 b' def test_get_ipython_dir_8():'
164 165 # test only when HOME directory actually writable
165 166 return
166 167
167 with patch.object(paths, '_writable_dir', lambda path: bool(path)), \
168 patch.object(paths, 'get_xdg_dir', return_value=None), \
169 modified_env({
170 'IPYTHON_DIR': None,
171 'IPYTHONDIR': None,
172 'HOME': '/',
173 }):
174 nt.assert_equal(paths.get_ipython_dir(), '/.ipython')
168 with patch.object(paths, "_writable_dir", lambda path: bool(path)), patch.object(
169 paths, "get_xdg_dir", return_value=None
170 ), modified_env(
171 {
172 "IPYTHON_DIR": None,
173 "IPYTHONDIR": None,
174 "HOME": "/",
175 }
176 ):
177 assert paths.get_ipython_dir() == "/.ipython"
175 178
176 179
177 180 def test_get_ipython_cache_dir():
@@ -181,18 +184,16 b' def test_get_ipython_cache_dir():'
181 184 os.makedirs(os.path.join(HOME_TEST_DIR, ".cache"))
182 185 with modified_env({'XDG_CACHE_HOME': None}):
183 186 ipdir = paths.get_ipython_cache_dir()
184 nt.assert_equal(os.path.join(HOME_TEST_DIR, ".cache", "ipython"),
185 ipdir)
187 assert os.path.join(HOME_TEST_DIR, ".cache", "ipython") == ipdir
186 188 assert_isdir(ipdir)
187 189
188 190 # test env override
189 191 with modified_env({"XDG_CACHE_HOME": XDG_CACHE_DIR}):
190 192 ipdir = paths.get_ipython_cache_dir()
191 193 assert_isdir(ipdir)
192 nt.assert_equal(ipdir, os.path.join(XDG_CACHE_DIR, "ipython"))
194 assert ipdir == os.path.join(XDG_CACHE_DIR, "ipython")
193 195 else:
194 nt.assert_equal(paths.get_ipython_cache_dir(),
195 paths.get_ipython_dir())
196 assert paths.get_ipython_cache_dir() == paths.get_ipython_dir()
196 197
197 198 def test_get_ipython_package_dir():
198 199 ipdir = paths.get_ipython_package_dir()
General Comments 0
You need to be logged in to leave comments. Login now