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

Skip to content

Commit e58571b

Browse files
committed
Fixes tests broken by issue #27781.
1 parent ee178e6 commit e58571b

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

Lib/test/test_genericpath.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,13 @@ def test_abspath(self):
388388
warnings.simplefilter("ignore", DeprecationWarning)
389389
self.assertIn(b"foo", self.pathmodule.abspath(b"foo"))
390390

391+
# avoid UnicodeDecodeError on Windows
392+
undecodable_path = b'' if sys.platform == 'win32' else b'f\xf2\xf2'
393+
391394
# Abspath returns bytes when the arg is bytes
392395
with warnings.catch_warnings():
393396
warnings.simplefilter("ignore", DeprecationWarning)
394-
for path in (b'', b'foo', b'f\xf2\xf2', b'/foo', b'C:\\'):
397+
for path in (b'', b'foo', undecodable_path, b'/foo', b'C:\\'):
395398
self.assertIsInstance(self.pathmodule.abspath(path), bytes)
396399

397400
def test_realpath(self):

Lib/test/test_httpservers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ def close_conn():
370370
return body
371371

372372
@support.requires_mac_ver(10, 5)
373+
@unittest.skipIf(sys.platform == 'win32',
374+
'undecodable name cannot be decoded on win32')
373375
@unittest.skipUnless(support.TESTFN_UNDECODABLE,
374376
'need support.TESTFN_UNDECODABLE')
375377
def test_undecodable_filename(self):

Lib/test/test_shutil.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,7 @@ def test_rmtree_works_on_bytes(self):
132132
write_file(os.path.join(victim, 'somefile'), 'foo')
133133
victim = os.fsencode(victim)
134134
self.assertIsInstance(victim, bytes)
135-
win = (os.name == 'nt')
136-
with self.assertWarns(DeprecationWarning) if win else ExitStack():
137-
shutil.rmtree(victim)
135+
shutil.rmtree(victim)
138136

139137
@support.skip_unless_symlink
140138
def test_rmtree_fails_on_symlink(self):

Lib/test/test_sys.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import gc
1111
import sysconfig
1212
import platform
13+
import locale
1314

1415
# count the number of test runs, used to create unique
1516
# strings to intern in test_intern()
@@ -627,6 +628,8 @@ def test_ioencoding(self):
627628

628629
@unittest.skipUnless(test.support.FS_NONASCII,
629630
'requires OS support of non-ASCII encodings')
631+
@unittest.skipUnless(sys.getfilesystemencoding() == locale.getpreferredencoding(False),
632+
'requires FS encoding to match locale')
630633
def test_ioencoding_nonascii(self):
631634
env = dict(os.environ)
632635

@@ -669,8 +672,6 @@ def test_getfilesystemencoding(self):
669672
fs_encoding = sys.getfilesystemencoding()
670673
if sys.platform == 'darwin':
671674
expected = 'utf-8'
672-
elif sys.platform == 'win32':
673-
expected = 'mbcs'
674675
else:
675676
expected = None
676677
self.check_fsencoding(fs_encoding, expected)

0 commit comments

Comments
 (0)