From 252855447eee7ff3bd70a1d864b14daed1bb704a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Mon, 28 May 2018 12:51:25 +0200 Subject: [PATCH] bpo-32374: Enhance test_importlib.test_bad_traverse() Make test_bad_traverse() fails if the script raises a Python exception: generic exit code 1. The test expects a crash which means an exit code different than 0 and 1. --- Lib/test/test_importlib/extension/test_loader.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py index 57ba7083d37d380..b3a3c74080df5b9 100644 --- a/Lib/test/test_importlib/extension/test_loader.py +++ b/Lib/test/test_importlib/extension/test_loader.py @@ -3,13 +3,12 @@ machinery = util.import_importlib('importlib.machinery') +import importlib.util import os.path +import subprocess import sys import types import unittest -import importlib.util -import importlib -from test.support.script_helper import assert_python_failure class LoaderTests(abc.LoaderTests): @@ -282,7 +281,11 @@ def test_bad_traverse(self): with support.SuppressCrashReport(): m = spec.loader.create_module(spec)""" - assert_python_failure("-c", script) + + proc = subprocess.run([sys.executable, "-c", script]) + # Expect a crash: exit code different than 0 (success) + # and 1 (generic Python error). + self.assertNotIn(proc.returncode, [0, 1]) (Frozen_MultiPhaseExtensionModuleTests,