diff Lib/test/test_ntpath.py @ 49410:ef4bb4d5dfde

Second part of #3187, for windows: os and os.path functions now accept both unicode and byte strings for file names. Reviewed by Guido.
author Amaury Forgeot d'Arc <amauryfa@gmail.com>
date Fri, 03 Oct 2008 18:38:26 +0000
parents 9c930a32cebb
children 5c55b9c80846
line wrap: on
line diff
--- a/Lib/test/test_ntpath.py	Fri Oct 03 16:38:30 2008 +0000
+++ b/Lib/test/test_ntpath.py	Fri Oct 03 18:38:26 2008 +0000
@@ -12,6 +12,23 @@
         raise TestFailed("%s should return: %s but returned: %s" \
               %(str(fn), str(wantResult), str(gotResult)))
 
+    # then with bytes
+    fn = fn.replace("('", "(b'")
+    fn = fn.replace('("', '(b"')
+    fn = fn.replace("['", "[b'")
+    fn = fn.replace('["', '[b"')
+    fn = fn.replace(", '", ", b'")
+    fn = fn.replace(', "', ', b"')
+    gotResult = eval(fn)
+    if isinstance(wantResult, str):
+        wantResult = wantResult.encode('ascii')
+    elif isinstance(wantResult, tuple):
+        wantResult = tuple(r.encode('ascii') for r in wantResult)
+
+    gotResult = eval(fn)
+    if wantResult != gotResult:
+        raise TestFailed("%s should return: %s but returned: %s" \
+              %(str(fn), str(wantResult), repr(gotResult)))
 
 class TestNtpath(unittest.TestCase):
     def test_splitext(self):