Staging
v0.5.1
https://github.com/python/cpython
Revision 8e2aa88a40c0c7611a04696d1789da159e40d7f7 authored by Serhiy Storchaka on 24 March 2015, 16:45:23 UTC, committed by Serhiy Storchaka on 24 March 2015, 16:45:23 UTC
1 parent 72bd327
Raw File
Tip revision: 8e2aa88a40c0c7611a04696d1789da159e40d7f7 authored by Serhiy Storchaka on 24 March 2015, 16:45:23 UTC
Issue #23741: Slightly refactor the pprint module to make it a little more
Tip revision: 8e2aa88
test_crashers.py
# 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
from test.script_helper import assert_python_failure

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):

    @unittest.skip("these tests are too fragile")
    @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.
            if test.support.verbose:
                print("Checking crasher:", fname)
            assert_python_failure(fname)


def test_main():
    test.support.run_unittest(CrasherTest)
    test.support.reap_children()

if __name__ == "__main__":
    test_main()
back to top