Show More
@@ -20,10 +20,10 from IPython.testing.decorators import skipif | |||||
20 | from nose import with_setup |
|
20 | from nose import with_setup | |
21 | from nose.tools import raises |
|
21 | from nose.tools import raises | |
22 |
|
22 | |||
|
23 | from os.path import join, abspath, split | |||
23 | import os, sys, IPython |
|
24 | import os, sys, IPython | |
24 | env = os.environ |
|
|||
25 |
|
25 | |||
26 | from os.path import join, abspath, split |
|
26 | env = os.environ | |
27 |
|
27 | |||
28 | try: |
|
28 | try: | |
29 | import _winreg as wreg |
|
29 | import _winreg as wreg | |
@@ -78,7 +78,7 def test_get_home_dir_1(): | |||||
78 | def test_get_home_dir_2(): |
|
78 | def test_get_home_dir_2(): | |
79 | """Testcase for py2exe logic, compressed lib |
|
79 | """Testcase for py2exe logic, compressed lib | |
80 | """ |
|
80 | """ | |
81 | sys.frozen=True |
|
81 | sys.frozen = True | |
82 | #fake filename for IPython.__init__ |
|
82 | #fake filename for IPython.__init__ | |
83 | IPython.__file__ = abspath(join(test_file_path, "home_test_dir/Library.zip/IPython/__init__.py")) |
|
83 | IPython.__file__ = abspath(join(test_file_path, "home_test_dir/Library.zip/IPython/__init__.py")) | |
84 |
|
84 | |||
@@ -88,7 +88,7 def test_get_home_dir_2(): | |||||
88 | @with_enivronment |
|
88 | @with_enivronment | |
89 | def test_get_home_dir_3(): |
|
89 | def test_get_home_dir_3(): | |
90 | """Testcase $HOME is set, then use its value as home directory.""" |
|
90 | """Testcase $HOME is set, then use its value as home directory.""" | |
91 | env["HOME"] = join(test_file_path,"home_test_dir") |
|
91 | env["HOME"] = join(test_file_path, "home_test_dir") | |
92 | home_dir = genutils.get_home_dir() |
|
92 | home_dir = genutils.get_home_dir() | |
93 | assert home_dir == env["HOME"] |
|
93 | assert home_dir == env["HOME"] | |
94 |
|
94 | |||
@@ -112,7 +112,7 def test_get_home_dir_5(): | |||||
112 |
|
112 | |||
113 | os.name = 'nt' |
|
113 | os.name = 'nt' | |
114 | del os.environ["HOME"] |
|
114 | del os.environ["HOME"] | |
115 | env['HOMEDRIVE'],env['HOMEPATH'] = os.path.abspath(test_file_path),"home_test_dir" |
|
115 | env['HOMEDRIVE'], env['HOMEPATH'] = os.path.abspath(test_file_path), "home_test_dir" | |
116 |
|
116 | |||
117 | home_dir = genutils.get_home_dir() |
|
117 | home_dir = genutils.get_home_dir() | |
118 | assert home_dir == abspath(join(test_file_path, "home_test_dir")) |
|
118 | assert home_dir == abspath(join(test_file_path, "home_test_dir")) | |
@@ -126,8 +126,8 def test_get_home_dir_6(): | |||||
126 |
|
126 | |||
127 | os.name = 'nt' |
|
127 | os.name = 'nt' | |
128 | del os.environ["HOME"] |
|
128 | del os.environ["HOME"] | |
129 | env['HOMEDRIVE'],env['HOMEPATH'] = os.path.abspath(test_file_path),"DOES NOT EXIST" |
|
129 | env['HOMEDRIVE'], env['HOMEPATH'] = os.path.abspath(test_file_path), "DOES NOT EXIST" | |
130 | env["USERPROFILE"] = abspath(join(test_file_path,"home_test_dir")) |
|
130 | env["USERPROFILE"] = abspath(join(test_file_path, "home_test_dir")) | |
131 |
|
131 | |||
132 | home_dir = genutils.get_home_dir() |
|
132 | home_dir = genutils.get_home_dir() | |
133 | assert home_dir == abspath(join(test_file_path, "home_test_dir")) |
|
133 | assert home_dir == abspath(join(test_file_path, "home_test_dir")) | |
@@ -140,7 +140,7 def test_get_home_dir_7(): | |||||
140 | env['HOMEDRIVE'],env['HOMEPATH'], env['USERPROFILE'] missing |
|
140 | env['HOMEDRIVE'],env['HOMEPATH'], env['USERPROFILE'] missing | |
141 | """ |
|
141 | """ | |
142 | os.name = 'nt' |
|
142 | os.name = 'nt' | |
143 | del env["HOME"],env['HOMEDRIVE'] |
|
143 | del env["HOME"], env['HOMEDRIVE'] | |
144 |
|
144 | |||
145 | #Stub windows registry functions |
|
145 | #Stub windows registry functions | |
146 | def OpenKey(x, y): |
|
146 | def OpenKey(x, y): | |
@@ -173,7 +173,7 def test_get_ipython_dir_1(): | |||||
173 | @with_enivronment |
|
173 | @with_enivronment | |
174 | def test_get_ipython_dir_2(): |
|
174 | def test_get_ipython_dir_2(): | |
175 | """3 Testcase to see if we can call get_ipython_dir without Exceptions.""" |
|
175 | """3 Testcase to see if we can call get_ipython_dir without Exceptions.""" | |
176 | genutils.get_home_dir=lambda : "someplace" |
|
176 | genutils.get_home_dir = lambda : "someplace" | |
177 | os.name = "posix" |
|
177 | os.name = "posix" | |
178 | ipdir = genutils.get_ipython_dir() |
|
178 | ipdir = genutils.get_ipython_dir() | |
179 | assert ipdir == os.path.abspath(os.path.join("someplace", ".ipython")) |
|
179 | assert ipdir == os.path.abspath(os.path.join("someplace", ".ipython")) | |
@@ -217,15 +217,15 def test_popkey_2(): | |||||
217 |
|
217 | |||
218 | def test_popkey_3(): |
|
218 | def test_popkey_3(): | |
219 | dct = dict(a=1, b=2, c=3) |
|
219 | dct = dict(a=1, b=2, c=3) | |
220 | assert genutils.popkey(dct, "A", 13)==13 |
|
220 | assert genutils.popkey(dct, "A", 13) == 13 | |
221 | assert dct == dict(a=1, b=2, c=3) |
|
221 | assert dct == dict(a=1, b=2, c=3) | |
222 | assert genutils.popkey(dct, "B", 14)==14 |
|
222 | assert genutils.popkey(dct, "B", 14) == 14 | |
223 | assert dct == dict(a=1, b=2, c=3) |
|
223 | assert dct == dict(a=1, b=2, c=3) | |
224 | assert genutils.popkey(dct, "C", 15)==15 |
|
224 | assert genutils.popkey(dct, "C", 15) == 15 | |
225 | assert dct == dict(a=1, b=2, c=3) |
|
225 | assert dct == dict(a=1, b=2, c=3) | |
226 | assert genutils.popkey(dct, "a")==1 |
|
226 | assert genutils.popkey(dct, "a") == 1 | |
227 | assert dct == dict(b=2, c=3) |
|
227 | assert dct == dict(b=2, c=3) | |
228 | assert genutils.popkey(dct, "b")==2 |
|
228 | assert genutils.popkey(dct, "b") == 2 | |
229 | assert dct == dict(c=3) |
|
229 | assert dct == dict(c=3) | |
230 | assert genutils.popkey(dct, "c")==3 |
|
230 | assert genutils.popkey(dct, "c") == 3 | |
231 | assert dct == dict() |
|
231 | assert dct == dict() |
General Comments 0
You need to be logged in to leave comments.
Login now