diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-10-16 22:05:04 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-10-16 22:05:04 (GMT) |
commit | 05b84439a3541ea3a2fdda9f8abfd46b64c431e8 (patch) | |
tree | e3c1054e86b2247190703d9273341048203ad16d /Lib/test/test_import.py | |
parent | 197332ae5a9d4885806b5cceafef650c4e8f8b77 (diff) | |
download | cpython-05b84439a3541ea3a2fdda9f8abfd46b64c431e8.zip cpython-05b84439a3541ea3a2fdda9f8abfd46b64c431e8.tar.gz cpython-05b84439a3541ea3a2fdda9f8abfd46b64c431e8.tar.bz2 |
Issue #21720: Improve exception message when the type of fromlist is unicode
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r-- | Lib/test/test_import.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 2abf5b2..4325005 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -415,6 +415,14 @@ class ImportTests(unittest.TestCase): finally: rmtree(dir_name) + def test_fromlist_type(self): + with self.assertRaises(TypeError) as cm: + __import__('encodings', fromlist=[u'aliases']) + self.assertIn('must be str, not unicode', str(cm.exception)) + with self.assertRaises(TypeError) as cm: + __import__('encodings', fromlist=[1]) + self.assertIn('must be str, not int', str(cm.exception)) + class PycRewritingTests(unittest.TestCase): # Test that the `co_filename` attribute on code objects always points |