##// END OF EJS Templates
Skip some more tests that require unicode paths
Thomas Kluyver -
Show More
@@ -17,6 +17,7 b' from os.path import join'
17 17
18 18 from IPython.core.completerlib import magic_run_completer, module_completion
19 19 from IPython.utils.tempdir import TemporaryDirectory
20 from IPython.testing.decorators import onlyif_unicode_paths
20 21
21 22
22 23 class MockEvent(object):
@@ -29,7 +30,7 b' class MockEvent(object):'
29 30 class Test_magic_run_completer(unittest.TestCase):
30 31 def setUp(self):
31 32 self.BASETESTDIR = tempfile.mkdtemp()
32 for fil in [u"aaø.py", u"a.py", u"b.py"]:
33 for fil in [u"aao.py", u"a.py", u"b.py"]:
33 34 with open(join(self.BASETESTDIR, fil), "w") as sfile:
34 35 sfile.write("pass\n")
35 36 self.oldpath = os.getcwdu()
@@ -45,7 +46,7 b' class Test_magic_run_completer(unittest.TestCase):'
45 46 event = MockEvent(u"%run a")
46 47 mockself = None
47 48 match = set(magic_run_completer(mockself, event))
48 self.assertEqual(match, set([u"a.py", u"aaø.py"]))
49 self.assertEqual(match, set([u"a.py", u"aao.py"]))
49 50
50 51 def test_2(self):
51 52 """Test magic_run_completer, should match one alterntive
@@ -53,14 +54,14 b' class Test_magic_run_completer(unittest.TestCase):'
53 54 event = MockEvent(u"%run aa")
54 55 mockself = None
55 56 match = set(magic_run_completer(mockself, event))
56 self.assertEqual(match, set([u"aaø.py"]))
57 self.assertEqual(match, set([u"aao.py"]))
57 58
58 59 def test_3(self):
59 60 """Test magic_run_completer with unterminated " """
60 61 event = MockEvent(u'%run "a')
61 62 mockself = None
62 63 match = set(magic_run_completer(mockself, event))
63 self.assertEqual(match, set([u"a.py", u"aaø.py"]))
64 self.assertEqual(match, set([u"a.py", u"aao.py"]))
64 65
65 66 def test_import_invalid_module(self):
66 67 """Testing of issue https://github.com/ipython/ipython/issues/1107"""
@@ -77,3 +78,43 b' class Test_magic_run_completer(unittest.TestCase):'
77 78 self.assertFalse(intersection, intersection)
78 79
79 80 assert valid_module_names.issubset(s), valid_module_names.intersection(s)
81
82 class Test_magic_run_completer_nonascii(unittest.TestCase):
83 @onlyif_unicode_paths
84 def setUp(self):
85 self.BASETESTDIR = tempfile.mkdtemp()
86 for fil in [u"aaø.py", u"a.py", u"b.py"]:
87 with open(join(self.BASETESTDIR, fil), "w") as sfile:
88 sfile.write("pass\n")
89 self.oldpath = os.getcwdu()
90 os.chdir(self.BASETESTDIR)
91
92 def tearDown(self):
93 os.chdir(self.oldpath)
94 shutil.rmtree(self.BASETESTDIR)
95
96 @onlyif_unicode_paths
97 def test_1(self):
98 """Test magic_run_completer, should match two alterntives
99 """
100 event = MockEvent(u"%run a")
101 mockself = None
102 match = set(magic_run_completer(mockself, event))
103 self.assertEqual(match, set([u"a.py", u"aaø.py"]))
104
105 @onlyif_unicode_paths
106 def test_2(self):
107 """Test magic_run_completer, should match one alterntive
108 """
109 event = MockEvent(u"%run aa")
110 mockself = None
111 match = set(magic_run_completer(mockself, event))
112 self.assertEqual(match, set([u"aaø.py"]))
113
114 @onlyif_unicode_paths
115 def test_3(self):
116 """Test magic_run_completer with unterminated " """
117 event = MockEvent(u'%run "a')
118 mockself = None
119 match = set(magic_run_completer(mockself, event))
120 self.assertEqual(match, set([u"a.py", u"aaø.py"]))
@@ -33,7 +33,7 b' from StringIO import StringIO'
33 33 import nose.tools as nt
34 34
35 35 # Our own
36 from IPython.testing.decorators import skipif
36 from IPython.testing.decorators import skipif, onlyif_unicode_paths
37 37 from IPython.testing import tools as tt
38 38 from IPython.utils import io
39 39
@@ -404,6 +404,7 b' class InteractiveShellTestCase(unittest.TestCase):'
404 404
405 405 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
406 406
407 @onlyif_unicode_paths
407 408 def setUp(self):
408 409 self.BASETESTDIR = tempfile.mkdtemp()
409 410 self.TESTDIR = join(self.BASETESTDIR, u"åäö")
@@ -418,6 +419,7 b' class TestSafeExecfileNonAsciiPath(unittest.TestCase):'
418 419 os.chdir(self.oldpath)
419 420 shutil.rmtree(self.BASETESTDIR)
420 421
422 @onlyif_unicode_paths
421 423 def test_1(self):
422 424 """Test safe_execfile with non-ascii path
423 425 """
@@ -425,6 +427,7 b' class TestSafeExecfileNonAsciiPath(unittest.TestCase):'
425 427
426 428
427 429 class TestSystemRaw(unittest.TestCase):
430 @onlyif_unicode_paths
428 431 def test_1(self):
429 432 """Test system_raw with non-ascii cmd
430 433 """
@@ -122,9 +122,11 b' def test_list_profiles_in():'
122 122 # the module-level teardown.
123 123 td = tempfile.mkdtemp(dir=TMP_TEST_DIR)
124 124 td = py3compat.str_to_unicode(td)
125 for name in ('profile_foo', u'profile_ünicode', 'profile_hello',
126 'not_a_profile'):
125 for name in ('profile_foo', 'profile_hello', 'not_a_profile'):
127 126 os.mkdir(os.path.join(td, name))
127 if dec.unicode_paths:
128 os.mkdir(os.path.join(td, u'profile_ünicode'))
129
128 130 with open(os.path.join(td, 'profile_file'), 'w') as f:
129 131 f.write("I am not a profile directory")
130 132 profiles = list_profiles_in(td)
@@ -139,7 +141,8 b' def test_list_profiles_in():'
139 141 profiles.remove(p)
140 142 found_unicode = True
141 143 break
142 nt.assert_true(found_unicode)
144 if dec.unicode_paths:
145 nt.assert_true(found_unicode)
143 146 nt.assert_equal(set(profiles), set(['foo', 'hello']))
144 147
145 148
@@ -63,6 +63,7 b' class PromptTests(unittest.TestCase):'
63 63 self.pm.in_template = r'\#>'
64 64 self.assertEqual(self.pm.render('in',color=False), '%d>' % ip.execution_count)
65 65
66 @dec.onlyif_unicode_paths
66 67 def test_render_unicode_cwd(self):
67 68 save = os.getcwdu()
68 69 with TemporaryDirectory(u'ünicødé') as td:
General Comments 0
You need to be logged in to leave comments. Login now