diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-08-06 20:29:29 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-08-06 20:29:29 (GMT) |
commit | febc3320563bf597e186ebce75abdac2926ceeb6 (patch) | |
tree | 1360725b7e65af72348ed78687257249ccf1d36e /Lib/test | |
parent | d73c31899e88aa5a1cc28f288cc70a35f2a196c2 (diff) | |
download | cpython-febc3320563bf597e186ebce75abdac2926ceeb6.zip cpython-febc3320563bf597e186ebce75abdac2926ceeb6.tar.gz cpython-febc3320563bf597e186ebce75abdac2926ceeb6.tar.bz2 |
Issue #26754: Undocumented support of general bytes-like objects
as path in compile() and similar functions is now deprecated.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_compile.py | 7 | ||||
-rw-r--r-- | Lib/test/test_parser.py | 10 | ||||
-rw-r--r-- | Lib/test/test_symtable.py | 6 | ||||
-rw-r--r-- | Lib/test/test_zipimport.py | 6 |
4 files changed, 21 insertions, 8 deletions
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py index 824e843..9638e69 100644 --- a/Lib/test/test_compile.py +++ b/Lib/test/test_compile.py @@ -473,10 +473,13 @@ if 1: self.assertEqual(d, {1: 2, 3: 4}) def test_compile_filename(self): - for filename in ('file.py', b'file.py', - bytearray(b'file.py'), memoryview(b'file.py')): + for filename in 'file.py', b'file.py': code = compile('pass', filename, 'exec') self.assertEqual(code.co_filename, 'file.py') + for filename in bytearray(b'file.py'), memoryview(b'file.py'): + with self.assertWarns(DeprecationWarning): + code = compile('pass', filename, 'exec') + self.assertEqual(code.co_filename, 'file.py') self.assertRaises(TypeError, compile, 'pass', list(b'file.py'), 'exec') @support.cpython_only diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py index 1e7d331..e2a42f9 100644 --- a/Lib/test/test_parser.py +++ b/Lib/test/test_parser.py @@ -632,12 +632,18 @@ class CompileTestCase(unittest.TestCase): self.assertEqual(code.co_filename, '<syntax-tree>') code = st.compile() self.assertEqual(code.co_filename, '<syntax-tree>') - for filename in ('file.py', b'file.py', - bytearray(b'file.py'), memoryview(b'file.py')): + for filename in 'file.py', b'file.py': code = parser.compilest(st, filename) self.assertEqual(code.co_filename, 'file.py') code = st.compile(filename) self.assertEqual(code.co_filename, 'file.py') + for filename in bytearray(b'file.py'), memoryview(b'file.py'): + with self.assertWarns(DeprecationWarning): + code = parser.compilest(st, filename) + self.assertEqual(code.co_filename, 'file.py') + with self.assertWarns(DeprecationWarning): + code = st.compile(filename) + self.assertEqual(code.co_filename, 'file.py') self.assertRaises(TypeError, parser.compilest, st, list(b'file.py')) self.assertRaises(TypeError, st.compile, list(b'file.py')) diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py index c5d7fac..bf99505 100644 --- a/Lib/test/test_symtable.py +++ b/Lib/test/test_symtable.py @@ -158,9 +158,11 @@ class SymtableTest(unittest.TestCase): checkfilename("def f(x): foo)(") # parse-time checkfilename("def f(x): global x") # symtable-build-time symtable.symtable("pass", b"spam", "exec") - with self.assertRaises(TypeError): + with self.assertWarns(DeprecationWarning), \ + self.assertRaises(TypeError): symtable.symtable("pass", bytearray(b"spam"), "exec") - symtable.symtable("pass", memoryview(b"spam"), "exec") + with self.assertWarns(DeprecationWarning): + symtable.symtable("pass", memoryview(b"spam"), "exec") with self.assertRaises(TypeError): symtable.symtable("pass", list(b"spam"), "exec") diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index 20491cd..a2482d4 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -629,8 +629,10 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): zipimport.zipimporter(filename) zipimport.zipimporter(os.fsencode(filename)) - zipimport.zipimporter(bytearray(os.fsencode(filename))) - zipimport.zipimporter(memoryview(os.fsencode(filename))) + with self.assertWarns(DeprecationWarning): + zipimport.zipimporter(bytearray(os.fsencode(filename))) + with self.assertWarns(DeprecationWarning): + zipimport.zipimporter(memoryview(os.fsencode(filename))) @support.requires_zlib |