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
------------------------------------------------------------------------
diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py
index 2955f49..50638a1 100644
--- a/Lib/test/test_genericpath.py
+++ b/Lib/test/test_genericpath.py
@@ -180,6 +180,9 @@
safe_rmdir(support.TESTFN)
+# Following TestCase is not supposed to be run from test_genericpath.
+# It is inherited by other test modules (macpath, ntpath, posixpath).
+
class CommonTest(GenericTest):
# The path module to be tested
pathmodule = None
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 @@
# 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 @@
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