Add test decorator onlyif_unicode_paths. #471

Merged
merged 2 commits into from May 26, 2011

Projects

None yet

2 participants

Owner

Some of our tests hit an error where unicode paths weren't supported. Since they're specifically to test unicode paths, it didn't make sense to change them. This adds a decorator which skips them in those circumstances.

Closes gh-466

@fperez fperez and 1 other commented on an outdated diff May 26, 2011
IPython/testing/decorators.py
@@ -318,3 +319,15 @@ skip_known_failure = knownfailureif(True,'This test is known to fail')
# 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"€")
fperez
fperez May 26, 2011 Owner

Looks good, but since you're putting explicit unicode in the file, it should carry an encoding mark at the top:

# -*- coding: utf-8 -*-
fperez
fperez May 26, 2011 Owner

Also, note that mkdtemp doesn't clean up the temporary directory. you might want to use instead

f = tempfile.NamedTemproraryFile(prefix=u"tmp€")
f.close()

This will ensure we don't leave junk behind after each run of these tests.

takluyver
takluyver May 26, 2011 Owner

I always seem to forget the encoding line. Will do on both counts.

Owner

@fperez: Followed your suggestions.

Owner
fperez commented May 26, 2011

Looks great, merge away!

@takluyver takluyver merged commit eeba6ff into ipython:master May 26, 2011
Owner

Rebased and merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment