[pypy-commit] pypy release-pypy2.7-5.x: add test for exception ordering on failed import (issue 2524)

mattip pypy.commits at gmail.com
Thu Mar 30 14:58:48 EDT 2017


Author: Matti Picus <matti.picus at gmail.com>
Branch: release-pypy2.7-5.x
Changeset: r90876:4f78163b13c0
Date: 2017-03-30 21:57 +0300
http://bitbucket.org/pypy/pypy/changeset/4f78163b13c0/

Log:	add test for exception ordering on failed import (issue 2524)
	(grafted from e7aebde27cfc6859eb65e83e40cc17a47b91be1d)

diff --git a/pypy/module/imp/test/test_import.py b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -361,7 +361,12 @@
         assert sys == o
 
     def test_import_fromlist_must_not_contain_unicodes(self):
-        raises(TypeError, __import__, 'encodings', None, None, [u'xxx'])
+        exc = raises(TypeError, __import__, 'encodings', None, None, [u'xxx'])
+        assert 'not a string' in exc.value.message
+        exc = raises(TypeError, __import__, 'encodings', None, None, [123])
+        assert 'not a string' in exc.value.message
+        # issue 2524
+        raises(ImportError, __import__, 'xxxbadmodule', fromlist=[u'xx']) 
 
     def test_import_relative_back_to_absolute2(self):
         from pkg import abs_x_y


More information about the pypy-commit mailing list