Show More
@@ -15,7 +15,7 b' import nose.tools as nt' | |||
|
15 | 15 | from IPython.config.loader import Config |
|
16 | 16 | from IPython.core import completer |
|
17 | 17 | from IPython.external.decorators import knownfailureif |
|
18 | from IPython.utils.tempdir import TemporaryDirectory | |
|
18 | from IPython.utils.tempdir import TemporaryDirectory, TemporaryWorkingDirectory | |
|
19 | 19 | from IPython.utils.generics import complete_object |
|
20 | 20 | from IPython.utils import py3compat |
|
21 | 21 | from IPython.utils.py3compat import string_types, unicode_type |
@@ -189,28 +189,22 b' def test_abspath_file_completions():' | |||
|
189 | 189 | |
|
190 | 190 | def test_local_file_completions(): |
|
191 | 191 | ip = get_ipython() |
|
192 | cwd = py3compat.getcwd() | |
|
193 | try: | |
|
194 | with TemporaryDirectory() as tmpdir: | |
|
195 | os.chdir(tmpdir) | |
|
196 | prefix = './foo' | |
|
197 | suffixes = ['1', '2'] | |
|
198 | names = [prefix+s for s in suffixes] | |
|
199 | for n in names: | |
|
200 | open(n, 'w').close() | |
|
201 | ||
|
202 | # Check simple completion | |
|
203 | c = ip.complete(prefix)[1] | |
|
204 | nt.assert_equal(c, names) | |
|
205 | ||
|
206 | # Now check with a function call | |
|
207 | cmd = 'a = f("%s' % prefix | |
|
208 | c = ip.complete(prefix, cmd)[1] | |
|
209 | comp = [prefix+s for s in suffixes] | |
|
210 | nt.assert_equal(c, comp) | |
|
211 | finally: | |
|
212 | # prevent failures from making chdir stick | |
|
213 | os.chdir(cwd) | |
|
192 | with TemporaryWorkingDirectory(): | |
|
193 | prefix = './foo' | |
|
194 | suffixes = ['1', '2'] | |
|
195 | names = [prefix+s for s in suffixes] | |
|
196 | for n in names: | |
|
197 | open(n, 'w').close() | |
|
198 | ||
|
199 | # Check simple completion | |
|
200 | c = ip.complete(prefix)[1] | |
|
201 | nt.assert_equal(c, names) | |
|
202 | ||
|
203 | # Now check with a function call | |
|
204 | cmd = 'a = f("%s' % prefix | |
|
205 | c = ip.complete(prefix, cmd)[1] | |
|
206 | comp = [prefix+s for s in suffixes] | |
|
207 | nt.assert_equal(c, comp) | |
|
214 | 208 | |
|
215 | 209 | |
|
216 | 210 | def test_greedy_completions(): |
@@ -8,7 +8,7 b' import os' | |||
|
8 | 8 | from IPython.testing import tools as tt, decorators as dec |
|
9 | 9 | from IPython.core.prompts import PromptManager, LazyEvaluate |
|
10 | 10 | from IPython.testing.globalipapp import get_ipython |
|
11 | from IPython.utils.tempdir import TemporaryDirectory | |
|
11 | from IPython.utils.tempdir import TemporaryWorkingDirectory | |
|
12 | 12 | from IPython.utils import py3compat |
|
13 | 13 | from IPython.utils.py3compat import unicode_type |
|
14 | 14 | |
@@ -67,13 +67,10 b' class PromptTests(unittest.TestCase):' | |||
|
67 | 67 | |
|
68 | 68 | @dec.onlyif_unicode_paths |
|
69 | 69 | def test_render_unicode_cwd(self): |
|
70 | save = py3compat.getcwd() | |
|
71 | with TemporaryDirectory(u'ünicødé') as td: | |
|
72 | os.chdir(td) | |
|
70 | with TemporaryWorkingDirectory(u'ünicødé'): | |
|
73 | 71 | self.pm.in_template = r'\w [\#]' |
|
74 | 72 | p = self.pm.render('in', color=False) |
|
75 | 73 | self.assertEqual(p, u"%s [%i]" % (py3compat.getcwd(), ip.execution_count)) |
|
76 | os.chdir(save) | |
|
77 | 74 | |
|
78 | 75 | def test_lazy_eval_unicode(self): |
|
79 | 76 | u = u'ünicødé' |
General Comments 0
You need to be logged in to leave comments.
Login now