summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pep277.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2010-08-09 17:18:05 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2010-08-09 17:18:05 (GMT)
commit87082ee14dd970526e65459804365a5699c7dd9a (patch)
treeb4bd4f8e9576dbf47afbaa9ce6b599cb12ea8fe7 /Lib/test/test_pep277.py
parentec882214fe84b1affeeafb324ac682cc1f6a4a69 (diff)
downloadcpython-87082ee14dd970526e65459804365a5699c7dd9a.zip
cpython-87082ee14dd970526e65459804365a5699c7dd9a.tar.gz
cpython-87082ee14dd970526e65459804365a5699c7dd9a.tar.bz2
Merged manually from 2.7 branch to 3.x trunk.
------------------------------------------------------------------------ r81149 | florent.xicluna | 2010-05-13 23:40:01 +0200 (jeu. 13 mai 2010) | 2 lignes Better test skipping, with message in the log. ------------------------------------------------------------------------ r81150 | florent.xicluna | 2010-05-13 23:41:05 +0200 (jeu. 13 mai 2010) | 2 lignes Improve test feedback to troubleshoot issue #8423 on OS X. ------------------------------------------------------------------------ r81151 | florent.xicluna | 2010-05-14 01:46:48 +0200 (ven. 14 mai 2010) | 2 lignes Revert changeset r81150 which helped diagnose issue #8423 on some OS X buildbot. ------------------------------------------------------------------------ r82056 | florent.xicluna | 2010-06-17 22:30:56 +0200 (jeu. 17 juin 2010) | 2 lignes Add few words about test.test_genericpath.CommonTest ------------------------------------------------------------------------
Diffstat (limited to 'Lib/test/test_pep277.py')
-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 aba1368..60d99db 100644
--- a/Lib/test/test_pep277.py
+++ b/Lib/test/test_pep277.py
@@ -40,6 +40,18 @@ if sys.platform != 'darwin':
# NFKC('\u2001') == NFKC('\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(support.TESTFN, self.norm(name))
- try:
- f = open(name, 'wb')
- 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, 'wb') as f:
+ f.write((name+'\n').encode("utf-8"))
os.stat(name)
files.add(name)
self.files = files