Skip some more tests that require unicode paths
Thomas Kluyver -
r12168:706dd916
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -17,6 +17,7 from os.path import join
17
17
18 from IPython.core.completerlib import magic_run_completer, module_completion
18 from IPython.core.completerlib import magic_run_completer, module_completion
19 from IPython.utils.tempdir import TemporaryDirectory
19 from IPython.utils.tempdir import TemporaryDirectory
20 from IPython.testing.decorators import onlyif_unicode_paths
20
21
21
22
22 class MockEvent(object):
23 class MockEvent(object):
@@ -29,7 +30,7 class MockEvent(object):
29 class Test_magic_run_completer(unittest.TestCase):
30 class Test_magic_run_completer(unittest.TestCase):
30 def setUp(self):
31 def setUp(self):
31 self.BASETESTDIR = tempfile.mkdtemp()
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 with open(join(self.BASETESTDIR, fil), "w") as sfile:
34 with open(join(self.BASETESTDIR, fil), "w") as sfile:
34 sfile.write("pass\n")
35 sfile.write("pass\n")
35 self.oldpath = os.getcwdu()
36 self.oldpath = os.getcwdu()
@@ -45,7 +46,7 class Test_magic_run_completer(unittest.TestCase):
45 event = MockEvent(u"%run a")
46 event = MockEvent(u"%run a")
46 mockself = None
47 mockself = None
47 match = set(magic_run_completer(mockself, event))
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 def test_2(self):
51 def test_2(self):
51 """Test magic_run_completer, should match one alterntive
52 """Test magic_run_completer, should match one alterntive
@@ -53,14 +54,14 class Test_magic_run_completer(unittest.TestCase):
53 event = MockEvent(u"%run aa")
54 event = MockEvent(u"%run aa")
54 mockself = None
55 mockself = None
55 match = set(magic_run_completer(mockself, event))
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 def test_3(self):
59 def test_3(self):
59 """Test magic_run_completer with unterminated " """
60 """Test magic_run_completer with unterminated " """
60 event = MockEvent(u'%run "a')
61 event = MockEvent(u'%run "a')
61 mockself = None
62 mockself = None
62 match = set(magic_run_completer(mockself, event))
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 def test_import_invalid_module(self):
66 def test_import_invalid_module(self):
66 """Testing of issue https://github.com/ipython/ipython/issues/1107"""
67 """Testing of issue https://github.com/ipython/ipython/issues/1107"""
@@ -77,3 +78,43 class Test_magic_run_completer(unittest.TestCase):
77 self.assertFalse(intersection, intersection)
78 self.assertFalse(intersection, intersection)
78
79
79 assert valid_module_names.issubset(s), valid_module_names.intersection(s)
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 from StringIO import StringIO
33 import nose.tools as nt
33 import nose.tools as nt
34
34
35 # Our own
35 # Our own
36 from IPython.testing.decorators import skipif
36 from IPython.testing.decorators import skipif, onlyif_unicode_paths
37 from IPython.testing import tools as tt
37 from IPython.testing import tools as tt
38 from IPython.utils import io
38 from IPython.utils import io
39
39
@@ -404,6 +404,7 class InteractiveShellTestCase(unittest.TestCase):
404
404
405 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
405 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
406
406
407 @onlyif_unicode_paths
407 def setUp(self):
408 def setUp(self):
408 self.BASETESTDIR = tempfile.mkdtemp()
409 self.BASETESTDIR = tempfile.mkdtemp()
409 self.TESTDIR = join(self.BASETESTDIR, u"åäö")
410 self.TESTDIR = join(self.BASETESTDIR, u"åäö")
@@ -418,6 +419,7 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
418 os.chdir(self.oldpath)
419 os.chdir(self.oldpath)
419 shutil.rmtree(self.BASETESTDIR)
420 shutil.rmtree(self.BASETESTDIR)
420
421
422 @onlyif_unicode_paths
421 def test_1(self):
423 def test_1(self):
422 """Test safe_execfile with non-ascii path
424 """Test safe_execfile with non-ascii path
423 """
425 """
@@ -425,6 +427,7 class TestSafeExecfileNonAsciiPath(unittest.TestCase):
425
427
426
428
427 class TestSystemRaw(unittest.TestCase):
429 class TestSystemRaw(unittest.TestCase):
430 @onlyif_unicode_paths
428 def test_1(self):
431 def test_1(self):
429 """Test system_raw with non-ascii cmd
432 """Test system_raw with non-ascii cmd
430 """
433 """
@@ -122,9 +122,11 def test_list_profiles_in():
122 # the module-level teardown.
122 # the module-level teardown.
123 td = tempfile.mkdtemp(dir=TMP_TEST_DIR)
123 td = tempfile.mkdtemp(dir=TMP_TEST_DIR)
124 td = py3compat.str_to_unicode(td)
124 td = py3compat.str_to_unicode(td)
125 for name in ('profile_foo', u'profile_ünicode', 'profile_hello',
125 for name in ('profile_foo', 'profile_hello', 'not_a_profile'):
126 'not_a_profile'):
127 os.mkdir(os.path.join(td, name))
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 with open(os.path.join(td, 'profile_file'), 'w') as f:
130 with open(os.path.join(td, 'profile_file'), 'w') as f:
129 f.write("I am not a profile directory")
131 f.write("I am not a profile directory")
130 profiles = list_profiles_in(td)
132 profiles = list_profiles_in(td)
@@ -139,7 +141,8 def test_list_profiles_in():
139 profiles.remove(p)
141 profiles.remove(p)
140 found_unicode = True
142 found_unicode = True
141 break
143 break
142 nt.assert_true(found_unicode)
144 if dec.unicode_paths:
145 nt.assert_true(found_unicode)
143 nt.assert_equal(set(profiles), set(['foo', 'hello']))
146 nt.assert_equal(set(profiles), set(['foo', 'hello']))
144
147
145
148
@@ -63,6 +63,7 class PromptTests(unittest.TestCase):
63 self.pm.in_template = r'\#>'
63 self.pm.in_template = r'\#>'
64 self.assertEqual(self.pm.render('in',color=False), '%d>' % ip.execution_count)
64 self.assertEqual(self.pm.render('in',color=False), '%d>' % ip.execution_count)
65
65
66 @dec.onlyif_unicode_paths
66 def test_render_unicode_cwd(self):
67 def test_render_unicode_cwd(self):
67 save = os.getcwdu()
68 save = os.getcwdu()
68 with TemporaryDirectory(u'ünicødé') as td:
69 with TemporaryDirectory(u'ünicødé') as td:
Comments 0
You need to be logged in to leave comments. Login now