test_crashers.py 1.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# Tests that the crashers in the Lib/test/crashers directory actually
# do crash the interpreter as expected
#
# If a crasher is fixed, it should be moved elsewhere in the test suite to
# ensure it continues to work correctly.

import unittest
import glob
import os.path
import test.support
11
from test.support.script_helper import assert_python_failure
12 13 14 15 16 17 18 19

CRASHER_DIR = os.path.join(os.path.dirname(__file__), "crashers")
CRASHER_FILES = os.path.join(CRASHER_DIR, "*.py")

infinite_loops = ["infinite_loop_re.py", "nasty_eq_vs_dict.py"]

class CrasherTest(unittest.TestCase):

Antoine Pitrou's avatar
Antoine Pitrou committed
20
    @unittest.skip("these tests are too fragile")
21 22 23 24 25 26 27
    @test.support.cpython_only
    def test_crashers_crash(self):
        for fname in glob.glob(CRASHER_FILES):
            if os.path.basename(fname) in infinite_loops:
                continue
            # Some "crashers" only trigger an exception rather than a
            # segfault. Consider that an acceptable outcome.
28 29
            if test.support.verbose:
                print("Checking crasher:", fname)
30 31 32
            assert_python_failure(fname)


33
def tearDownModule():
34 35 36
    test.support.reap_children()

if __name__ == "__main__":
37
    unittest.main()