Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 683a7e7

Browse files
committed
Merged revisions 78585,78594,78606 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r78585 | florent.xicluna | 2010-03-02 22:34:45 +0100 (mar, 02 mar 2010) | 2 lines Tentatively enable test_pep277 on all platforms. ........ r78594 | florent.xicluna | 2010-03-02 23:34:11 +0100 (mar, 02 mar 2010) | 2 lines Test test_pep277 is only relevant for Unicode-friendly filesystems. ........ r78606 | florent.xicluna | 2010-03-03 00:56:38 +0100 (mer, 03 mar 2010) | 2 lines Fix wording. ........
1 parent 4fd181c commit 683a7e7

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

Lib/test/test_pep277.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir
33
import sys, os, unittest
44
from test import support
5-
if not os.path.supports_unicode_filenames:
6-
raise unittest.SkipTest("test works only on NT+")
75

86
filenames = [
97
'abc',
@@ -36,7 +34,12 @@ def setUp(self):
3634
except OSError:
3735
pass
3836
for name in self.files:
39-
f = open(name, 'wb')
37+
try:
38+
f = open(name, 'wb')
39+
except UnicodeEncodeError:
40+
if not os.path.supports_unicode_filenames:
41+
raise unittest.SkipTest("only NT+ and systems with Unicode"
42+
"-friendly filesystem encoding")
4043
f.write((name+'\n').encode("utf-8"))
4144
f.close()
4245
os.stat(name)
@@ -51,6 +54,9 @@ def _apply_failure(self, fn, filename, expected_exception,
5154
raise support.TestFailed("Expected to fail calling '%s(%r)'"
5255
% (fn.__name__, filename))
5356
except expected_exception as details:
57+
# the "filename" exception attribute may be encoded
58+
if isinstance(details.filename, bytes):
59+
filename = filename.encode(sys.getfilesystemencoding())
5460
if check_fn_in_exception and details.filename != filename:
5561
raise support.TestFailed("Function '%s(%r) failed with "
5662
"bad filename in the exception: %r"
@@ -80,7 +86,7 @@ def test_listdir(self):
8086
f1 = os.listdir(support.TESTFN)
8187
f2 = os.listdir(str(support.TESTFN.encode("utf-8"),
8288
sys.getfilesystemencoding()))
83-
sf2 = set("\\".join((str(support.TESTFN), f))
89+
sf2 = set(os.path.join(str(support.TESTFN), f)
8490
for f in f2)
8591
self.assertEqual(len(f1), len(self.files))
8692
self.assertEqual(sf2, set(self.files))

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,9 @@ Documentation
824824
Tests
825825
-----
826826

827+
- Issue #767675: enable test_pep277 on POSIX platforms with Unicode-friendly
828+
filesystem encoding.
829+
827830
- Issue #6292: for the moment at least, the test suite runs cleanly if python
828831
is run with the -OO flag. Tests requiring docstrings are skipped.
829832

0 commit comments

Comments
 (0)