Show More
@@ -22,6 +22,7 b' from nose.tools import raises' | |||
|
22 | 22 | |
|
23 | 23 | from os.path import join, abspath, split |
|
24 | 24 | import os, sys, IPython |
|
25 | import nose.tools as nt | |
|
25 | 26 | |
|
26 | 27 | env = os.environ |
|
27 | 28 | |
@@ -72,7 +73,7 b' def test_get_home_dir_1():' | |||
|
72 | 73 | IPython.__file__ = abspath(join(test_file_path, "home_test_dir/Lib/IPython/__init__.py")) |
|
73 | 74 | |
|
74 | 75 | home_dir = genutils.get_home_dir() |
|
75 |
assert |
|
|
76 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir"))) | |
|
76 | 77 | |
|
77 | 78 | @with_enivronment |
|
78 | 79 | def test_get_home_dir_2(): |
@@ -83,14 +84,14 b' def test_get_home_dir_2():' | |||
|
83 | 84 | IPython.__file__ = abspath(join(test_file_path, "home_test_dir/Library.zip/IPython/__init__.py")) |
|
84 | 85 | |
|
85 | 86 | home_dir = genutils.get_home_dir() |
|
86 |
assert |
|
|
87 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir")).lower()) | |
|
87 | 88 | |
|
88 | 89 | @with_enivronment |
|
89 | 90 | def test_get_home_dir_3(): |
|
90 | 91 | """Testcase $HOME is set, then use its value as home directory.""" |
|
91 | 92 | env["HOME"] = join(test_file_path, "home_test_dir") |
|
92 | 93 | home_dir = genutils.get_home_dir() |
|
93 |
assert |
|
|
94 | nt.assert_equal(home_dir, env["HOME"]) | |
|
94 | 95 | |
|
95 | 96 | @with_enivronment |
|
96 | 97 | def test_get_home_dir_4(): |
@@ -99,11 +100,7 b' def test_get_home_dir_4():' | |||
|
99 | 100 | |
|
100 | 101 | os.name = 'posix' |
|
101 | 102 | del os.environ["HOME"] |
|
102 | try: | |
|
103 | genutils.get_home_dir() | |
|
104 | assert False | |
|
105 | except genutils.HomeDirError: | |
|
106 | pass | |
|
103 | nt.assert_raises(genutils.HomeDirError, genutils.get_home_dir) | |
|
107 | 104 | |
|
108 | 105 | @with_enivronment |
|
109 | 106 | def test_get_home_dir_5(): |
@@ -115,7 +112,7 b' def test_get_home_dir_5():' | |||
|
115 | 112 | env['HOMEDRIVE'], env['HOMEPATH'] = os.path.abspath(test_file_path), "home_test_dir" |
|
116 | 113 | |
|
117 | 114 | home_dir = genutils.get_home_dir() |
|
118 |
assert |
|
|
115 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir"))) | |
|
119 | 116 | |
|
120 | 117 | @with_enivronment |
|
121 | 118 | def test_get_home_dir_6(): |
@@ -130,7 +127,7 b' def test_get_home_dir_6():' | |||
|
130 | 127 | env["USERPROFILE"] = abspath(join(test_file_path, "home_test_dir")) |
|
131 | 128 | |
|
132 | 129 | home_dir = genutils.get_home_dir() |
|
133 |
assert |
|
|
130 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir"))) | |
|
134 | 131 | |
|
135 | 132 | # Should we stub wreg fully so we can run the test on all platforms? |
|
136 | 133 | #@skip_if_not_win32 |
@@ -155,7 +152,7 b' def test_get_home_dir_7():' | |||
|
155 | 152 | wreg.QueryValueEx = QueryValueEx |
|
156 | 153 | |
|
157 | 154 | home_dir = genutils.get_home_dir() |
|
158 |
assert |
|
|
155 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir"))) | |
|
159 | 156 | |
|
160 | 157 | |
|
161 | 158 | # |
@@ -167,7 +164,7 b' def test_get_ipython_dir_1():' | |||
|
167 | 164 | """2 Testcase to see if we can call get_ipython_dir without Exceptions.""" |
|
168 | 165 | env['IPYTHONDIR'] = "someplace/.ipython" |
|
169 | 166 | ipdir = genutils.get_ipython_dir() |
|
170 |
assert |
|
|
167 | nt.assert_equal(ipdir, os.path.abspath("someplace/.ipython")) | |
|
171 | 168 | |
|
172 | 169 | |
|
173 | 170 | @with_enivronment |
@@ -176,7 +173,7 b' def test_get_ipython_dir_2():' | |||
|
176 | 173 | genutils.get_home_dir = lambda : "someplace" |
|
177 | 174 | os.name = "posix" |
|
178 | 175 | ipdir = genutils.get_ipython_dir() |
|
179 |
assert |
|
|
176 | nt.assert_equal(ipdir, os.path.abspath(os.path.join("someplace", ".ipython"))) | |
|
180 | 177 | |
|
181 | 178 | @with_enivronment |
|
182 | 179 | def test_get_ipython_dir_3(): |
@@ -184,7 +181,7 b' def test_get_ipython_dir_3():' | |||
|
184 | 181 | genutils.get_home_dir = lambda : "someplace" |
|
185 | 182 | os.name = "nt" |
|
186 | 183 | ipdir = genutils.get_ipython_dir() |
|
187 |
assert |
|
|
184 | nt.assert_equal(ipdir, os.path.abspath(os.path.join("someplace", "_ipython"))) | |
|
188 | 185 | |
|
189 | 186 | |
|
190 | 187 | # |
@@ -203,29 +200,28 b' def test_get_security_dir():' | |||
|
203 | 200 | |
|
204 | 201 | def test_popkey_1(): |
|
205 | 202 | dct = dict(a=1, b=2, c=3) |
|
206 |
assert |
|
|
207 |
assert |
|
|
208 |
assert |
|
|
209 |
assert |
|
|
210 |
assert |
|
|
211 |
assert |
|
|
212 | ||
|
213 | @raises(KeyError) | |
|
203 | nt.assert_equal(genutils.popkey(dct, "a"), 1) | |
|
204 | nt.assert_equal(dct, dict(b=2, c=3)) | |
|
205 | nt.assert_equal(genutils.popkey(dct, "b"), 2) | |
|
206 | nt.assert_equal(dct, dict(c=3)) | |
|
207 | nt.assert_equal(genutils.popkey(dct, "c"), 3) | |
|
208 | nt.assert_equal(dct, dict()) | |
|
209 | ||
|
214 | 210 | def test_popkey_2(): |
|
215 | 211 | dct = dict(a=1, b=2, c=3) |
|
216 |
genutils.popkey |
|
|
212 | nt.assert_raises(KeyError, genutils.popkey, dct, "d") | |
|
217 | 213 | |
|
218 | 214 | def test_popkey_3(): |
|
219 | 215 | dct = dict(a=1, b=2, c=3) |
|
220 |
assert |
|
|
221 |
assert |
|
|
222 |
assert |
|
|
223 |
assert |
|
|
224 |
assert |
|
|
225 |
assert |
|
|
226 |
assert |
|
|
227 |
assert |
|
|
228 |
assert |
|
|
229 |
assert |
|
|
230 |
assert |
|
|
231 |
assert |
|
|
216 | nt.assert_equal(genutils.popkey(dct, "A", 13), 13) | |
|
217 | nt.assert_equal(dct, dict(a=1, b=2, c=3)) | |
|
218 | nt.assert_equal(genutils.popkey(dct, "B", 14), 14) | |
|
219 | nt.assert_equal(dct, dict(a=1, b=2, c=3)) | |
|
220 | nt.assert_equal(genutils.popkey(dct, "C", 15), 15) | |
|
221 | nt.assert_equal(dct, dict(a=1, b=2, c=3)) | |
|
222 | nt.assert_equal(genutils.popkey(dct, "a"), 1) | |
|
223 | nt.assert_equal(dct, dict(b=2, c=3)) | |
|
224 | nt.assert_equal(genutils.popkey(dct, "b"), 2) | |
|
225 | nt.assert_equal(dct, dict(c=3)) | |
|
226 | nt.assert_equal(genutils.popkey(dct, "c"), 3) | |
|
227 | nt.assert_equal(dct, dict()) |
General Comments 0
You need to be logged in to leave comments.
Login now