##// END OF EJS Templates
fix various tests on Windows...
Min RK -
Show More
@@ -2833,6 +2833,9 b' Defaulting color scheme to \'NoColor\'"""'
2833 2833 raise UsageError("Bookmark '%s' not found. "
2834 2834 "Use '%%bookmark -l' to see your bookmarks." % ps)
2835 2835
2836 # strip extra quotes on Windows, because os.chdir doesn't like them
2837 if sys.platform == 'win32':
2838 ps = ps.strip('\'"')
2836 2839 # at this point ps should point to the target dir
2837 2840 if ps:
2838 2841 try:
@@ -14,6 +14,7 b' import nose.tools as nt'
14 14
15 15 # our own packages
16 16 from IPython.core import completer
17 from IPython.external.decorators import knownfailureif
17 18 from IPython.utils.tempdir import TemporaryDirectory
18 19
19 20 #-----------------------------------------------------------------------------
@@ -136,12 +137,33 b' def test_has_open_quotes4():'
136 137 for s in ['""', '""" """', '"hi" "ipython"']:
137 138 nt.assert_false(completer.has_open_quotes(s))
138 139
140 @knownfailureif(sys.platform == 'win32', "abspath completions fail on Windows")
141 def test_abspath_file_completions():
142 ip = get_ipython()
143 with TemporaryDirectory() as tmpdir:
144 prefix = os.path.join(tmpdir, 'foo')
145 suffixes = map(str, [1,2])
146 names = [prefix+s for s in suffixes]
147 for n in names:
148 open(n, 'w').close()
139 149
140 def test_file_completions():
150 # Check simple completion
151 c = ip.complete(prefix)[1]
152 nt.assert_equal(c, names)
153
154 # Now check with a function call
155 cmd = 'a = f("%s' % prefix
156 c = ip.complete(prefix, cmd)[1]
157 comp = [prefix+s for s in suffixes]
158 nt.assert_equal(c, comp)
141 159
160 def test_local_file_completions():
142 161 ip = get_ipython()
162 cwd = os.getcwdu()
163 try:
143 164 with TemporaryDirectory() as tmpdir:
144 prefix = os.path.join(tmpdir, 'foo')
165 os.chdir(tmpdir)
166 prefix = './foo'
145 167 suffixes = map(str, [1,2])
146 168 names = [prefix+s for s in suffixes]
147 169 for n in names:
@@ -156,3 +178,6 b' def test_file_completions():'
156 178 c = ip.complete(prefix, cmd)[1]
157 179 comp = [prefix+s for s in suffixes]
158 180 nt.assert_equal(c, comp)
181 finally:
182 # prevent failures from making chdir stick
183 os.chdir(cwd)
@@ -301,8 +301,8 b' def test_parse_options():'
301 301
302 302 def test_dirops():
303 303 """Test various directory handling operations."""
304 curpath = lambda :os.path.splitdrive(os.getcwdu())[1].replace('\\','/')
305
304 # curpath = lambda :os.path.splitdrive(os.getcwdu())[1].replace('\\','/')
305 curpath = os.getcwdu
306 306 startdir = os.getcwdu()
307 307 ipdir = _ip.ipython_dir
308 308 try:
@@ -101,7 +101,9 b' def test_info():'
101 101 fname = __file__
102 102 if fname.endswith(".pyc"):
103 103 fname = fname[:-1]
104 nt.assert_equal(i['file'], fname)
104 # case-insensitive comparison needed on some filesystems
105 # e.g. Windows:
106 nt.assert_equal(i['file'].lower(), fname.lower())
105 107 nt.assert_equal(i['definition'], 'Call(self, *a, **kw)\n')
106 108 nt.assert_equal(i['docstring'], Call.__doc__)
107 109 nt.assert_equal(i['source'], None)
@@ -17,6 +17,7 b' import sys'
17 17 import tempfile
18 18
19 19 import nose.tools as nt
20 from nose import SkipTest
20 21
21 22 from IPython.testing import decorators as dec
22 23 from IPython.testing import tools as tt
@@ -156,7 +157,11 b' class TestMagicRunSimple(tt.TempFileMixin):'
156 157
157 158 def test_obj_del(self):
158 159 """Test that object's __del__ methods are called on exit."""
159
160 if sys.platform == 'win32':
161 try:
162 import win32api
163 except ImportError:
164 raise SkipTest("Test requires pywin32")
160 165 src = ("class A(object):\n"
161 166 " def __del__(self):\n"
162 167 " print 'object A deleted'\n"
@@ -143,6 +143,7 b' def test_get_home_dir_3():'
143 143
144 144
145 145 @with_environment
146 @skip_win32
146 147 def test_get_home_dir_4():
147 148 """Testcase $HOME is not set, os=='posix'.
148 149 This should fail with HomeDirError"""
@@ -227,9 +228,10 b' def test_get_home_dir_8():'
227 228 @with_environment
228 229 def test_get_ipython_dir_1():
229 230 """test_get_ipython_dir_1, Testcase to see if we can call get_ipython_dir without Exceptions."""
230 env['IPYTHON_DIR'] = "someplace/.ipython"
231 env_ipdir = os.path.join("someplace", ".ipython")
232 env['IPYTHON_DIR'] = env_ipdir
231 233 ipdir = path.get_ipython_dir()
232 nt.assert_equal(ipdir, "someplace/.ipython")
234 nt.assert_equal(ipdir, env_ipdir)
233 235
234 236
235 237 @with_environment
@@ -293,8 +295,8 b' def test_get_ipython_dir_6():'
293 295 @with_environment
294 296 def test_get_ipython_dir_7():
295 297 """test_get_ipython_dir_7, test home directory expansion on IPYTHON_DIR"""
296 home_dir = os.path.expanduser('~/')
297 env['IPYTHON_DIR'] = '~/somewhere'
298 home_dir = os.path.expanduser('~')
299 env['IPYTHON_DIR'] = os.path.join('~', 'somewhere')
298 300 ipdir = path.get_ipython_dir()
299 301 nt.assert_equal(ipdir, os.path.join(home_dir, 'somewhere'))
300 302
General Comments 0
You need to be logged in to leave comments. Login now