summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-05-13 21:40:01 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-05-13 21:40:01 (GMT)
commit9ac6114dc9e2a8ddac0244d70e69a6feae498550 (patch)
tree86cd7ac4ca0b5c3387505cf07f620561dd786663
parent8c72b4e931545afb4f5793b0ca62aae6cf0fa80c (diff)
downloadcpython-9ac6114dc9e2a8ddac0244d70e69a6feae498550.zip
cpython-9ac6114dc9e2a8ddac0244d70e69a6feae498550.tar.gz
cpython-9ac6114dc9e2a8ddac0244d70e69a6feae498550.tar.bz2
Better test skipping, with message in the log.
-rw-r--r--Lib/test/test_pep277.py22
1 files changed, 14 insertions, 8 deletions
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py
index 7b527de..b09329d 100644
--- a/Lib/test/test_pep277.py
+++ b/Lib/test/test_pep277.py
@@ -40,6 +40,18 @@ if sys.platform != 'darwin':
# NFKC(u'\u2001') == NFKC(u'\u2003')
])
+
+# Is it Unicode-friendly?
+if not os.path.supports_unicode_filenames:
+ fsencoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
+ try:
+ for name in filenames:
+ name.encode(fsencoding)
+ except UnicodeEncodeError:
+ raise unittest.SkipTest("only NT+ and systems with "
+ "Unicode-friendly filesystem encoding")
+
+
# Destroy directory dirname and all files under it, to one level.
def deltree(dirname):
# Don't hide legitimate errors: if one of these suckers exists, it's
@@ -63,14 +75,8 @@ class UnicodeFileTests(unittest.TestCase):
files = set()
for name in self.files:
name = os.path.join(test_support.TESTFN, self.norm(name))
- try:
- f = open(name, 'w')
- except UnicodeEncodeError:
- if not os.path.supports_unicode_filenames:
- self.skipTest("only NT+ and systems with Unicode-friendly"
- "filesystem encoding")
- f.write((name+'\n').encode("utf-8"))
- f.close()
+ with open(name, 'w') as f:
+ f.write((name+'\n').encode("utf-8"))
os.stat(name)
files.add(name)
self.files = files