summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pep277.py
diff options
context:
space:
mode:
authorFlorent Xicluna <florent.xicluna@gmail.com>2011-11-07 20:56:17 (GMT)
committerFlorent Xicluna <florent.xicluna@gmail.com>2011-11-07 20:56:17 (GMT)
commite0912db24e33fa50b7dcb009b6a1a69bb17826c7 (patch)
treec00c487763471d9a7ec688723a8d9dd2013cf285 /Lib/test/test_pep277.py
parent7ef53ef916453fc2d907ae783aa0bd5801aa5575 (diff)
downloadcpython-e0912db24e33fa50b7dcb009b6a1a69bb17826c7.zip
cpython-e0912db24e33fa50b7dcb009b6a1a69bb17826c7.tar.gz
cpython-e0912db24e33fa50b7dcb009b6a1a69bb17826c7.tar.bz2
Closes #13366: fix test_pep277 failure on Windows.
Diffstat (limited to 'Lib/test/test_pep277.py')
-rw-r--r--Lib/test/test_pep277.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py
index 602c064..df4b592 100644
--- a/Lib/test/test_pep277.py
+++ b/Lib/test/test_pep277.py
@@ -96,9 +96,10 @@ class UnicodeFileTests(unittest.TestCase):
with self.assertRaises(expected_exception) as c:
fn(filename)
exc_filename = c.exception.filename
- # the "filename" exception attribute may be encoded
- if isinstance(exc_filename, bytes):
- filename = filename.encode(sys.getfilesystemencoding())
+ # listdir may append a wildcard to the filename
+ if fn is os.listdir and sys.platform == 'win32':
+ exc_filename, _, wildcard = exc_filename.rpartition(os.sep)
+ self.assertEqual(wildcard, r'*.*')
if check_filename:
self.assertEqual(exc_filename, filename, "Function '%s(%a) failed "
"with bad filename in the exception: %a" %
@@ -113,8 +114,12 @@ class UnicodeFileTests(unittest.TestCase):
self._apply_failure(os.chdir, name)
self._apply_failure(os.rmdir, name)
self._apply_failure(os.remove, name)
- # listdir may append a wildcard to the filename, so dont check
- self._apply_failure(os.listdir, name, check_filename=False)
+ self._apply_failure(os.listdir, name)
+
+ if sys.platform == 'win32':
+ _listdir_failure = FileNotFoundError
+ else:
+ _listdir_failure = NotADirectoryError
def test_open(self):
for name in self.files:
@@ -122,7 +127,7 @@ class UnicodeFileTests(unittest.TestCase):
f.write((name+'\n').encode("utf-8"))
f.close()
os.stat(name)
- self._apply_failure(os.listdir, name, NotADirectoryError)
+ self._apply_failure(os.listdir, name, self._listdir_failure)
# Skip the test on darwin, because darwin does normalize the filename to
# NFD (a variant of Unicode NFD form). Normalize the filename to NFC, NFKC,
@@ -142,7 +147,7 @@ class UnicodeFileTests(unittest.TestCase):
self._apply_failure(os.rmdir, name)
self._apply_failure(os.remove, name)
# listdir may append a wildcard to the filename, so dont check
- self._apply_failure(os.listdir, name, check_filename=False)
+ self._apply_failure(os.listdir, name)
# Skip the test on darwin, because darwin uses a normalization different
# than Python NFD normalization: filenames are different even if we use