diff --git a/IPython/core/tests/test_completerlib.py b/IPython/core/tests/test_completerlib.py index 65f6564..b16f6c6 100644 --- a/IPython/core/tests/test_completerlib.py +++ b/IPython/core/tests/test_completerlib.py @@ -17,6 +17,7 @@ from os.path import join from IPython.core.completerlib import magic_run_completer, module_completion from IPython.utils.tempdir import TemporaryDirectory +from IPython.testing.decorators import onlyif_unicode_paths class MockEvent(object): @@ -29,7 +30,7 @@ class MockEvent(object): class Test_magic_run_completer(unittest.TestCase): def setUp(self): self.BASETESTDIR = tempfile.mkdtemp() - for fil in [u"aaø.py", u"a.py", u"b.py"]: + for fil in [u"aao.py", u"a.py", u"b.py"]: with open(join(self.BASETESTDIR, fil), "w") as sfile: sfile.write("pass\n") self.oldpath = os.getcwdu() @@ -45,7 +46,7 @@ class Test_magic_run_completer(unittest.TestCase): event = MockEvent(u"%run a") mockself = None match = set(magic_run_completer(mockself, event)) - self.assertEqual(match, set([u"a.py", u"aaø.py"])) + self.assertEqual(match, set([u"a.py", u"aao.py"])) def test_2(self): """Test magic_run_completer, should match one alterntive @@ -53,14 +54,14 @@ class Test_magic_run_completer(unittest.TestCase): event = MockEvent(u"%run aa") mockself = None match = set(magic_run_completer(mockself, event)) - self.assertEqual(match, set([u"aaø.py"])) + self.assertEqual(match, set([u"aao.py"])) def test_3(self): """Test magic_run_completer with unterminated " """ event = MockEvent(u'%run "a') mockself = None match = set(magic_run_completer(mockself, event)) - self.assertEqual(match, set([u"a.py", u"aaø.py"])) + self.assertEqual(match, set([u"a.py", u"aao.py"])) def test_import_invalid_module(self): """Testing of issue https://github.com/ipython/ipython/issues/1107""" @@ -77,3 +78,43 @@ class Test_magic_run_completer(unittest.TestCase): self.assertFalse(intersection, intersection) assert valid_module_names.issubset(s), valid_module_names.intersection(s) + +class Test_magic_run_completer_nonascii(unittest.TestCase): + @onlyif_unicode_paths + def setUp(self): + self.BASETESTDIR = tempfile.mkdtemp() + for fil in [u"aaø.py", u"a.py", u"b.py"]: + with open(join(self.BASETESTDIR, fil), "w") as sfile: + sfile.write("pass\n") + self.oldpath = os.getcwdu() + os.chdir(self.BASETESTDIR) + + def tearDown(self): + os.chdir(self.oldpath) + shutil.rmtree(self.BASETESTDIR) + + @onlyif_unicode_paths + def test_1(self): + """Test magic_run_completer, should match two alterntives + """ + event = MockEvent(u"%run a") + mockself = None + match = set(magic_run_completer(mockself, event)) + self.assertEqual(match, set([u"a.py", u"aaø.py"])) + + @onlyif_unicode_paths + def test_2(self): + """Test magic_run_completer, should match one alterntive + """ + event = MockEvent(u"%run aa") + mockself = None + match = set(magic_run_completer(mockself, event)) + self.assertEqual(match, set([u"aaø.py"])) + + @onlyif_unicode_paths + def test_3(self): + """Test magic_run_completer with unterminated " """ + event = MockEvent(u'%run "a') + mockself = None + match = set(magic_run_completer(mockself, event)) + self.assertEqual(match, set([u"a.py", u"aaø.py"])) diff --git a/IPython/core/tests/test_interactiveshell.py b/IPython/core/tests/test_interactiveshell.py index 8121b95..954f60c 100644 --- a/IPython/core/tests/test_interactiveshell.py +++ b/IPython/core/tests/test_interactiveshell.py @@ -33,7 +33,7 @@ from StringIO import StringIO import nose.tools as nt # Our own -from IPython.testing.decorators import skipif +from IPython.testing.decorators import skipif, onlyif_unicode_paths from IPython.testing import tools as tt from IPython.utils import io @@ -404,6 +404,7 @@ class InteractiveShellTestCase(unittest.TestCase): class TestSafeExecfileNonAsciiPath(unittest.TestCase): + @onlyif_unicode_paths def setUp(self): self.BASETESTDIR = tempfile.mkdtemp() self.TESTDIR = join(self.BASETESTDIR, u"åäö") @@ -418,6 +419,7 @@ class TestSafeExecfileNonAsciiPath(unittest.TestCase): os.chdir(self.oldpath) shutil.rmtree(self.BASETESTDIR) + @onlyif_unicode_paths def test_1(self): """Test safe_execfile with non-ascii path """ @@ -425,6 +427,7 @@ class TestSafeExecfileNonAsciiPath(unittest.TestCase): class TestSystemRaw(unittest.TestCase): + @onlyif_unicode_paths def test_1(self): """Test system_raw with non-ascii cmd """ diff --git a/IPython/core/tests/test_profile.py b/IPython/core/tests/test_profile.py index 09bad66..e9d399d 100644 --- a/IPython/core/tests/test_profile.py +++ b/IPython/core/tests/test_profile.py @@ -122,9 +122,11 @@ def test_list_profiles_in(): # the module-level teardown. td = tempfile.mkdtemp(dir=TMP_TEST_DIR) td = py3compat.str_to_unicode(td) - for name in ('profile_foo', u'profile_ünicode', 'profile_hello', - 'not_a_profile'): + for name in ('profile_foo', 'profile_hello', 'not_a_profile'): os.mkdir(os.path.join(td, name)) + if dec.unicode_paths: + os.mkdir(os.path.join(td, u'profile_ünicode')) + with open(os.path.join(td, 'profile_file'), 'w') as f: f.write("I am not a profile directory") profiles = list_profiles_in(td) @@ -139,7 +141,8 @@ def test_list_profiles_in(): profiles.remove(p) found_unicode = True break - nt.assert_true(found_unicode) + if dec.unicode_paths: + nt.assert_true(found_unicode) nt.assert_equal(set(profiles), set(['foo', 'hello'])) diff --git a/IPython/core/tests/test_prompts.py b/IPython/core/tests/test_prompts.py index 45cbeea..df765d5 100644 --- a/IPython/core/tests/test_prompts.py +++ b/IPython/core/tests/test_prompts.py @@ -63,6 +63,7 @@ class PromptTests(unittest.TestCase): self.pm.in_template = r'\#>' self.assertEqual(self.pm.render('in',color=False), '%d>' % ip.execution_count) + @dec.onlyif_unicode_paths def test_render_unicode_cwd(self): save = os.getcwdu() with TemporaryDirectory(u'ünicødé') as td: