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

Skip to content

Commit 304e542

Browse files
Issue #20056: Fixed deprecation warning about bytes path in test_shutil on
Windows. Path by Vajrasky Kok.
2 parents dd50b0a + 41ad77c commit 304e542

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/test/test_shutil.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import errno
1111
import functools
1212
import subprocess
13+
from contextlib import ExitStack
1314
from test import support
1415
from test.support import TESTFN
1516
from os.path import splitdrive
@@ -122,7 +123,9 @@ def test_rmtree_works_on_bytes(self):
122123
write_file(os.path.join(victim, 'somefile'), 'foo')
123124
victim = os.fsencode(victim)
124125
self.assertIsInstance(victim, bytes)
125-
shutil.rmtree(victim)
126+
win = (os.name == 'nt')
127+
with self.assertWarns(DeprecationWarning) if win else ExitStack():
128+
shutil.rmtree(victim)
126129

127130
@support.skip_unless_symlink
128131
def test_rmtree_fails_on_symlink(self):

0 commit comments

Comments
 (0)