]> granicus.if.org Git - python/commitdiff
bpo-33465: Use an unlikely to be built-in C extension in a test (#6797)
authorBarry Warsaw <barry@python.org>
Tue, 15 May 2018 18:41:13 +0000 (14:41 -0400)
committerGitHub <noreply@github.com>
Tue, 15 May 2018 18:41:13 +0000 (14:41 -0400)
Lib/test/test_import/__init__.py

index c23fac1ecc24d79bdecf37c19c86ff666f62fe82..fb9453ad0b39203b25fbb35868a8ee955c74c783 100644 (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: