Issue #13374: The Windows bytes API has been deprecated in the os module. Use

Unicode filenames instead of bytes filenames to not depend on the ANSI code
page anymore and to support any filename.
This commit is contained in:
Victor Stinner 2011-11-15 22:27:41 +01:00
parent 6166519d2b
commit 1ab6c2d2c2
8 changed files with 264 additions and 169 deletions

View file

@ -2,11 +2,12 @@
Tests common to genericpath, macpath, ntpath and posixpath
"""
import unittest
from test import support
import os
import genericpath
import os
import sys
import unittest
import warnings
from test import support
def safe_rmdir(dirname):
@ -258,7 +259,9 @@ class CommonTest(GenericTest):
def test_abspath(self):
self.assertIn("foo", self.pathmodule.abspath("foo"))
self.assertIn(b"foo", self.pathmodule.abspath(b"foo"))
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
self.assertIn(b"foo", self.pathmodule.abspath(b"foo"))
# Abspath returns bytes when the arg is bytes
for path in (b'', b'foo', b'f\xf2\xf2', b'/foo', b'C:\\'):
@ -266,7 +269,9 @@ class CommonTest(GenericTest):
def test_realpath(self):
self.assertIn("foo", self.pathmodule.realpath("foo"))
self.assertIn(b"foo", self.pathmodule.realpath(b"foo"))
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
self.assertIn(b"foo", self.pathmodule.realpath(b"foo"))
def test_normpath_issue5827(self):
# Make sure normpath preserves unicode
@ -296,8 +301,10 @@ class CommonTest(GenericTest):
"Mac OS X denies the creation of a directory with an invalid utf8 name")
def test_nonascii_abspath(self):
# Test non-ASCII, non-UTF8 bytes in the path.
with support.temp_cwd(b'\xe7w\xf0'):
self.test_abspath()
with warnings.catch_warnings():
warnings.simplefilter("ignore", DeprecationWarning)
with support.temp_cwd(b'\xe7w\xf0'):
self.test_abspath()
def test_main():