summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_os.py9
-rw-r--r--Lib/test/test_posix.py4
2 files changed, 11 insertions, 2 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index aa9b538748..d8920d99c5 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -2626,6 +2626,7 @@ class OSErrorTests(unittest.TestCase):
else:
encoded = os.fsencode(support.TESTFN)
self.bytes_filenames.append(encoded)
+ self.bytes_filenames.append(bytearray(encoded))
self.bytes_filenames.append(memoryview(encoded))
self.filenames = self.bytes_filenames + self.unicode_filenames
@@ -2699,8 +2700,14 @@ class OSErrorTests(unittest.TestCase):
for filenames, func, *func_args in funcs:
for name in filenames:
try:
- with bytes_filename_warn(False):
+ if isinstance(name, str):
func(name, *func_args)
+ elif isinstance(name, bytes):
+ with bytes_filename_warn(False):
+ func(name, *func_args)
+ else:
+ with self.assertWarnsRegex(DeprecationWarning, 'should be'):
+ func(name, *func_args)
except OSError as err:
self.assertIs(err.filename, name)
else:
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 6a1c82917a..de22513e34 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -407,8 +407,10 @@ class PosixTester(unittest.TestCase):
def test_stat(self):
self.assertTrue(posix.stat(support.TESTFN))
self.assertTrue(posix.stat(os.fsencode(support.TESTFN)))
- self.assertTrue(posix.stat(bytearray(os.fsencode(support.TESTFN))))
+ self.assertWarnsRegex(DeprecationWarning,
+ 'should be string, bytes or integer, not',
+ posix.stat, bytearray(os.fsencode(support.TESTFN)))
self.assertRaisesRegex(TypeError,
'should be string, bytes or integer, not',
posix.stat, None)