Show More
@@ -16,7 +16,7 b' __docformat__ = "restructuredtext en"' | |||||
16 | #----------------------------------------------------------------------------- |
|
16 | #----------------------------------------------------------------------------- | |
17 |
|
17 | |||
18 | from IPython import genutils |
|
18 | from IPython import genutils | |
19 | from IPython.testing.decorators import skipif |
|
19 | from IPython.testing.decorators import skipif, skip_if_not_win32 | |
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 | |||
@@ -38,7 +38,6 b' except ImportError:' | |||||
38 |
|
38 | |||
39 | test_file_path = split(abspath(__file__))[0] |
|
39 | test_file_path = split(abspath(__file__))[0] | |
40 |
|
40 | |||
41 |
|
||||
42 | # |
|
41 | # | |
43 | # Setup/teardown functions/decorators |
|
42 | # Setup/teardown functions/decorators | |
44 | # |
|
43 | # | |
@@ -95,7 +94,7 b' def teardown_environment():' | |||||
95 | (wreg.OpenKey, wreg.QueryValueEx,) = platformstuff |
|
94 | (wreg.OpenKey, wreg.QueryValueEx,) = platformstuff | |
96 |
|
95 | |||
97 | # Build decorator that uses the setup_environment/setup_environment |
|
96 | # Build decorator that uses the setup_environment/setup_environment | |
98 |
with_enivronment = with_setup(setup_environment, |
|
97 | with_enivronment = with_setup(setup_environment, teardown_environment) | |
99 |
|
98 | |||
100 |
|
99 | |||
101 | # |
|
100 | # | |
@@ -114,13 +113,14 b' def test_get_home_dir_1():' | |||||
114 | home_dir = genutils.get_home_dir() |
|
113 | home_dir = genutils.get_home_dir() | |
115 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir"))) |
|
114 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir"))) | |
116 |
|
115 | |||
|
116 | @skip_if_not_win32 | |||
117 | @with_enivronment |
|
117 | @with_enivronment | |
118 | def test_get_home_dir_2(): |
|
118 | def test_get_home_dir_2(): | |
119 | """Testcase for py2exe logic, compressed lib |
|
119 | """Testcase for py2exe logic, compressed lib | |
120 | """ |
|
120 | """ | |
121 | sys.frozen = True |
|
121 | sys.frozen = True | |
122 | #fake filename for IPython.__init__ |
|
122 | #fake filename for IPython.__init__ | |
123 | IPython.__file__ = abspath(join(test_file_path, "home_test_dir/Library.zip/IPython/__init__.py")) |
|
123 | IPython.__file__ = abspath(join(test_file_path, "home_test_dir/Library.zip/IPython/__init__.py")).lower() | |
124 |
|
124 | |||
125 | home_dir = genutils.get_home_dir() |
|
125 | home_dir = genutils.get_home_dir() | |
126 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir")).lower()) |
|
126 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir")).lower()) | |
@@ -134,20 +134,20 b' def test_get_home_dir_3():' | |||||
134 |
|
134 | |||
135 | @with_enivronment |
|
135 | @with_enivronment | |
136 | def test_get_home_dir_4(): |
|
136 | def test_get_home_dir_4(): | |
137 |
"""Testcase $HOME is not set, os=='po |
|
137 | """Testcase $HOME is not set, os=='poix'. | |
138 | This should fail with HomeDirError""" |
|
138 | This should fail with HomeDirError""" | |
139 |
|
139 | |||
140 | os.name = 'posix' |
|
140 | os.name = 'posix' | |
141 | del os.environ["HOME"] |
|
141 | if 'HOME' in env: del env['HOME'] | |
142 | nt.assert_raises(genutils.HomeDirError, genutils.get_home_dir) |
|
142 | nt.assert_raises(genutils.HomeDirError, genutils.get_home_dir) | |
143 |
|
143 | |||
144 | @with_enivronment |
|
144 | @with_enivronment | |
145 | def test_get_home_dir_5(): |
|
145 | def test_get_home_dir_5(): | |
146 | """Testcase $HOME is not set, os=='nt' |
|
146 | """Testcase $HOME is not set, os=='nt' | |
147 | env['HOMEDRIVE'],env['HOMEPATH'] points to path.""" |
|
147 | env['HOMEDRIVE'],env['HOMEPATH'] points to path.""" | |
148 |
|
148 | |||
149 | os.name = 'nt' |
|
149 | os.name = 'nt' | |
150 | del os.environ["HOME"] |
|
150 | if 'HOME' in env: del env['HOME'] | |
151 | env['HOMEDRIVE'], env['HOMEPATH'] = os.path.abspath(test_file_path), "home_test_dir" |
|
151 | env['HOMEDRIVE'], env['HOMEPATH'] = os.path.abspath(test_file_path), "home_test_dir" | |
152 |
|
152 | |||
153 | home_dir = genutils.get_home_dir() |
|
153 | home_dir = genutils.get_home_dir() | |
@@ -161,7 +161,7 b' def test_get_home_dir_6():' | |||||
161 | """ |
|
161 | """ | |
162 |
|
162 | |||
163 | os.name = 'nt' |
|
163 | os.name = 'nt' | |
164 | del os.environ["HOME"] |
|
164 | if 'HOME' in env: del env['HOME'] | |
165 | env['HOMEDRIVE'], env['HOMEPATH'] = os.path.abspath(test_file_path), "DOES NOT EXIST" |
|
165 | env['HOMEDRIVE'], env['HOMEPATH'] = os.path.abspath(test_file_path), "DOES NOT EXIST" | |
166 | env["USERPROFILE"] = abspath(join(test_file_path, "home_test_dir")) |
|
166 | env["USERPROFILE"] = abspath(join(test_file_path, "home_test_dir")) | |
167 |
|
167 | |||
@@ -169,14 +169,15 b' def test_get_home_dir_6():' | |||||
169 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir"))) |
|
169 | nt.assert_equal(home_dir, abspath(join(test_file_path, "home_test_dir"))) | |
170 |
|
170 | |||
171 | # Should we stub wreg fully so we can run the test on all platforms? |
|
171 | # Should we stub wreg fully so we can run the test on all platforms? | |
172 |
|
|
172 | @skip_if_not_win32 | |
173 | @with_enivronment |
|
173 | @with_enivronment | |
174 | def test_get_home_dir_7(): |
|
174 | def test_get_home_dir_7(): | |
175 | """Testcase $HOME is not set, os=='nt' |
|
175 | """Testcase $HOME is not set, os=='nt' | |
176 | env['HOMEDRIVE'],env['HOMEPATH'], env['USERPROFILE'] missing |
|
176 | env['HOMEDRIVE'],env['HOMEPATH'], env['USERPROFILE'] missing | |
177 | """ |
|
177 | """ | |
178 | os.name = 'nt' |
|
178 | os.name = 'nt' | |
179 | del env["HOME"], env['HOMEDRIVE'] |
|
179 | if 'HOME' in env: del env['HOME'] | |
|
180 | if 'HOMEDRIVE' in env: del env['HOMEDRIVE'] | |||
180 |
|
181 | |||
181 | #Stub windows registry functions |
|
182 | #Stub windows registry functions | |
182 | def OpenKey(x, y): |
|
183 | def OpenKey(x, y): |
General Comments 0
You need to be logged in to leave comments.
Login now