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