summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_genericpath.py3
-rw-r--r--Lib/test/test_pep277.py22
2 files changed, 17 insertions, 8 deletions
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 @@ class GenericTest(unittest.TestCase):
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 @@ 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