Author: Ronan Lamy <ronan.l...@gmail.com> Branch: testing-cleanup Changeset: r85082:a8d876855ca5 Date: 2016-06-10 18:34 +0100 http://bitbucket.org/pypy/pypy/changeset/a8d876855ca5/
Log: Turn the windows error box workaround into a fixture diff --git a/pypy/module/cpyext/test/conftest.py b/pypy/module/cpyext/test/conftest.py --- a/pypy/module/cpyext/test/conftest.py +++ b/pypy/module/cpyext/test/conftest.py @@ -1,4 +1,4 @@ -import py +import os import pytest def pytest_configure(config): @@ -21,3 +21,14 @@ def pytest_funcarg__api(request): return request.cls.api +if os.name == 'nt': + @pytest.yield_fixture(autouse=True, scope='session') + def prevent_dialog_box(): + """Do not open dreaded dialog box on segfault on Windows""" + import ctypes + SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN + old_err_mode = ctypes.windll.kernel32.GetErrorMode() + new_err_mode = old_err_mode | SEM_NOGPFAULTERRORBOX + ctypes.windll.kernel32.SetErrorMode(new_err_mode) + yield + ctypes.windll.kernel32.SetErrorMode(old_err_mode) diff --git a/pypy/module/cpyext/test/test_cpyext.py b/pypy/module/cpyext/test/test_cpyext.py --- a/pypy/module/cpyext/test/test_cpyext.py +++ b/pypy/module/cpyext/test/test_cpyext.py @@ -18,21 +18,6 @@ from rpython.tool import leakfinder from rpython.rlib import rawrefcount -def setup_module(module): - if os.name == 'nt': - # Do not open dreaded dialog box on segfault - import ctypes - SEM_NOGPFAULTERRORBOX = 0x0002 # From MSDN - old_err_mode = ctypes.windll.kernel32.GetErrorMode() - new_err_mode = old_err_mode | SEM_NOGPFAULTERRORBOX - ctypes.windll.kernel32.SetErrorMode(new_err_mode) - module.old_err_mode = old_err_mode - -def teardown_module(module): - if os.name == 'nt': - import ctypes - ctypes.windll.kernel32.SetErrorMode(module.old_err_mode) - @api.cpython_api([], api.PyObject) def PyPy_Crash1(space): 1/0 _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit