##// END OF EJS Templates
fix various tests on Windows...
Min RK -
Show More
@@ -2832,10 +2832,13 b' Defaulting color scheme to \'NoColor\'"""'
2832 if opts.has_key('b'):
2832 if opts.has_key('b'):
2833 raise UsageError("Bookmark '%s' not found. "
2833 raise UsageError("Bookmark '%s' not found. "
2834 "Use '%%bookmark -l' to see your bookmarks." % ps)
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 # at this point ps should point to the target dir
2839 # at this point ps should point to the target dir
2837 if ps:
2840 if ps:
2838 try:
2841 try:
2839 os.chdir(os.path.expanduser(ps))
2842 os.chdir(os.path.expanduser(ps))
2840 if hasattr(self.shell, 'term_title') and self.shell.term_title:
2843 if hasattr(self.shell, 'term_title') and self.shell.term_title:
2841 set_term_title('IPython: ' + abbrev_cwd())
2844 set_term_title('IPython: ' + abbrev_cwd())
@@ -14,6 +14,7 b' import nose.tools as nt'
14
14
15 # our own packages
15 # our own packages
16 from IPython.core import completer
16 from IPython.core import completer
17 from IPython.external.decorators import knownfailureif
17 from IPython.utils.tempdir import TemporaryDirectory
18 from IPython.utils.tempdir import TemporaryDirectory
18
19
19 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
@@ -136,9 +137,8 b' def test_has_open_quotes4():'
136 for s in ['""', '""" """', '"hi" "ipython"']:
137 for s in ['""', '""" """', '"hi" "ipython"']:
137 nt.assert_false(completer.has_open_quotes(s))
138 nt.assert_false(completer.has_open_quotes(s))
138
139
139
140 @knownfailureif(sys.platform == 'win32', "abspath completions fail on Windows")
140 def test_file_completions():
141 def test_abspath_file_completions():
141
142 ip = get_ipython()
142 ip = get_ipython()
143 with TemporaryDirectory() as tmpdir:
143 with TemporaryDirectory() as tmpdir:
144 prefix = os.path.join(tmpdir, 'foo')
144 prefix = os.path.join(tmpdir, 'foo')
@@ -156,3 +156,28 b' def test_file_completions():'
156 c = ip.complete(prefix, cmd)[1]
156 c = ip.complete(prefix, cmd)[1]
157 comp = [prefix+s for s in suffixes]
157 comp = [prefix+s for s in suffixes]
158 nt.assert_equal(c, comp)
158 nt.assert_equal(c, comp)
159
160 def test_local_file_completions():
161 ip = get_ipython()
162 cwd = os.getcwdu()
163 try:
164 with TemporaryDirectory() as tmpdir:
165 os.chdir(tmpdir)
166 prefix = './foo'
167 suffixes = map(str, [1,2])
168 names = [prefix+s for s in suffixes]
169 for n in names:
170 open(n, 'w').close()
171
172 # Check simple completion
173 c = ip.complete(prefix)[1]
174 nt.assert_equal(c, names)
175
176 # Now check with a function call
177 cmd = 'a = f("%s' % prefix
178 c = ip.complete(prefix, cmd)[1]
179 comp = [prefix+s for s in suffixes]
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 def test_dirops():
302 def test_dirops():
303 """Test various directory handling operations."""
303 """Test various directory handling operations."""
304 curpath = lambda :os.path.splitdrive(os.getcwdu())[1].replace('\\','/')
304 # curpath = lambda :os.path.splitdrive(os.getcwdu())[1].replace('\\','/')
305
305 curpath = os.getcwdu
306 startdir = os.getcwdu()
306 startdir = os.getcwdu()
307 ipdir = _ip.ipython_dir
307 ipdir = _ip.ipython_dir
308 try:
308 try:
@@ -101,7 +101,9 b' def test_info():'
101 fname = __file__
101 fname = __file__
102 if fname.endswith(".pyc"):
102 if fname.endswith(".pyc"):
103 fname = fname[:-1]
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 nt.assert_equal(i['definition'], 'Call(self, *a, **kw)\n')
107 nt.assert_equal(i['definition'], 'Call(self, *a, **kw)\n')
106 nt.assert_equal(i['docstring'], Call.__doc__)
108 nt.assert_equal(i['docstring'], Call.__doc__)
107 nt.assert_equal(i['source'], None)
109 nt.assert_equal(i['source'], None)
@@ -17,6 +17,7 b' import sys'
17 import tempfile
17 import tempfile
18
18
19 import nose.tools as nt
19 import nose.tools as nt
20 from nose import SkipTest
20
21
21 from IPython.testing import decorators as dec
22 from IPython.testing import decorators as dec
22 from IPython.testing import tools as tt
23 from IPython.testing import tools as tt
@@ -156,7 +157,11 b' class TestMagicRunSimple(tt.TempFileMixin):'
156
157
157 def test_obj_del(self):
158 def test_obj_del(self):
158 """Test that object's __del__ methods are called on exit."""
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 src = ("class A(object):\n"
165 src = ("class A(object):\n"
161 " def __del__(self):\n"
166 " def __del__(self):\n"
162 " print 'object A deleted'\n"
167 " print 'object A deleted'\n"
@@ -143,6 +143,7 b' def test_get_home_dir_3():'
143
143
144
144
145 @with_environment
145 @with_environment
146 @skip_win32
146 def test_get_home_dir_4():
147 def test_get_home_dir_4():
147 """Testcase $HOME is not set, os=='posix'.
148 """Testcase $HOME is not set, os=='posix'.
148 This should fail with HomeDirError"""
149 This should fail with HomeDirError"""
@@ -227,9 +228,10 b' def test_get_home_dir_8():'
227 @with_environment
228 @with_environment
228 def test_get_ipython_dir_1():
229 def test_get_ipython_dir_1():
229 """test_get_ipython_dir_1, Testcase to see if we can call get_ipython_dir without Exceptions."""
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 ipdir = path.get_ipython_dir()
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 @with_environment
237 @with_environment
@@ -293,8 +295,8 b' def test_get_ipython_dir_6():'
293 @with_environment
295 @with_environment
294 def test_get_ipython_dir_7():
296 def test_get_ipython_dir_7():
295 """test_get_ipython_dir_7, test home directory expansion on IPYTHON_DIR"""
297 """test_get_ipython_dir_7, test home directory expansion on IPYTHON_DIR"""
296 home_dir = os.path.expanduser('~/')
298 home_dir = os.path.expanduser('~')
297 env['IPYTHON_DIR'] = '~/somewhere'
299 env['IPYTHON_DIR'] = os.path.join('~', 'somewhere')
298 ipdir = path.get_ipython_dir()
300 ipdir = path.get_ipython_dir()
299 nt.assert_equal(ipdir, os.path.join(home_dir, 'somewhere'))
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