From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Wed, 16 May 2018 08:35:06 +0000 (-0700) Subject: bpo-32384: Skip test when _testcapi isn't available (GH-4940) X-Git-Tag: v3.7.0b5~111 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4af6110f77e141779492995fd168d4f027fcf3cf;p=python bpo-32384: Skip test when _testcapi isn't available (GH-4940) (cherry picked from commit 4cc3eb48e1e8289df5153db1c701cae263a1ef86) Co-authored-by: Isaiah Peng --- diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 7360b34023..7a21cb7e95 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -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):