bpo-33465: Use an unlikely to be built-in C extension in a test (GH-6797) (#6869)

(cherry picked from commit 8709b236fc)

Co-authored-by: Barry Warsaw <barry@python.org>
This commit is contained in:
Miss Islington (bot) 2018-05-15 14:24:26 -07:00 committed by Barry Warsaw
parent 820219f786
commit 2cdb70ac5d
1 changed files with 6 additions and 5 deletions

View File

@ -90,13 +90,14 @@ class ImportTests(unittest.TestCase):
self.assertEqual(cm.exception.path, os.__file__)
self.assertRegex(str(cm.exception), r"cannot import name 'i_dont_exist' from 'os' \(.*os.py\)")
@cpython_only
def test_from_import_missing_attr_has_name_and_so_path(self):
import select
import _testcapi
with self.assertRaises(ImportError) as cm:
from select import i_dont_exist
self.assertEqual(cm.exception.name, 'select')
self.assertEqual(cm.exception.path, select.__file__)
self.assertRegex(str(cm.exception), r"cannot import name 'i_dont_exist' from 'select' \(.*\.(so|pyd)\)")
from _testcapi import i_dont_exist
self.assertEqual(cm.exception.name, '_testcapi')
self.assertEqual(cm.exception.path, _testcapi.__file__)
self.assertRegex(str(cm.exception), r"cannot import name 'i_dont_exist' from '_testcapi' \(.*\.(so|pyd)\)")
def test_from_import_missing_attr_has_name(self):
with self.assertRaises(ImportError) as cm: