Permalink
Browse files

Add test decorator onlyif_unicode_paths.

Closes gh-466
  • Loading branch information...
1 parent 2973561 commit df86e70ed2318a149e80469e1b75ba5bf076088c @takluyver committed May 24, 2011
Showing with 17 additions and 1 deletion.
  1. +4 −1 IPython/core/tests/test_application.py
  2. +13 −0 IPython/testing/decorators.py
@@ -5,7 +5,9 @@
import tempfile
from IPython.core.application import Application
+from IPython.testing import decorators as testdec
+@testdec.onlyif_unicode_paths
def test_unicode_cwd():
"""Check that IPython starts with non-ascii characters in the path."""
wd = tempfile.mkdtemp(suffix=u"")
@@ -32,7 +34,8 @@ def test_unicode_cwd():
app.load_file_config(suppress_errors=False)
finally:
os.chdir(old_wd)
-
+
+@testdec.onlyif_unicode_paths
def test_unicode_ipdir():
"""Check that IPython starts with non-ascii characters in the IP dir."""
ipdir = tempfile.mkdtemp(suffix=u"")
@@ -49,6 +49,7 @@
# Stdlib imports
import inspect
import sys
+import tempfile
import unittest
# Third-party imports
@@ -318,3 +319,15 @@ def module_not_available(module):
# A null 'decorator', useful to make more readable code that needs to pick
# between different decorators based on OS or other conditions
null_deco = lambda f: f
+
+# Some tests only run where we can use unicode paths. Note that we can't just
+# check os.path.supports_unicode_filenames, which is always False on Linux.
+try:
+ tempfile.mkdtemp(u"")
+except UnicodeEncodeError:
+ unicode_paths = False
+else:
+ unicode_paths = True
+
+onlyif_unicode_paths = onlyif(unicode_paths, ("This test is only applicable "
+ "where we can use unicode in filenames."))

0 comments on commit df86e70

Please sign in to comment.