]> granicus.if.org Git - python/commitdiff
bpo-32384: Skip test when _testcapi isn't available (GH-4940)
authorIsaiah Peng <isaiah@users.noreply.github.com>
Wed, 16 May 2018 08:05:17 +0000 (10:05 +0200)
committerBerker Peksag <berker.peksag@gmail.com>
Wed, 16 May 2018 08:05:17 +0000 (11:05 +0300)
Lib/test/test_generators.py

index 7360b34023d3d8f691583cc57805be9851efe52d..7a21cb7e954ad5b999bdc8abb7a2daf0b5eac479 100644 (file)
@@ -9,12 +9,18 @@ import inspect
 
 from test import support
 
-_testcapi = support.import_module('_testcapi')
+try:
+    import _testcapi
+except ImportError:
+    _testcapi = None
 
 
 # This tests to make sure that if a SIGINT arrives just before we send into a
 # yield from chain, the KeyboardInterrupt is raised in the innermost
 # generator (see bpo-30039).
+@unittest.skipUnless(_testcapi is not None and
+                     hasattr(_testcapi, "raise_SIGINT_then_send_None"),
+                     "needs _testcapi.raise_SIGINT_then_send_None")
 class SignalAndYieldFromTest(unittest.TestCase):
 
     def generator1(self):