From 3998b70ff6e5268e828d87d4afde39aa7f867dee Mon Sep 17 00:00:00 2001 From: Anthony Shaw Date: Wed, 28 Mar 2018 09:02:37 +1100 Subject: [PATCH] add test for custom environment variable --- testing/test_pdb.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 4d768585c..165d53c1c 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -545,6 +545,30 @@ class TestDebuggingBreakpoints(object): ]) assert custom_debugger_hook == ["init", "set_trace"] + @pytest.mark.parametrize('args', [('',), ()]) + @pytest.mark.skipif(not SUPPORTS_BREAKPOINT_BUILTIN, reason="Requires breakpoint() builtin") + def test_environ_custom_class(self, testdir, custom_debugger_hook, args): + testdir.makeconftest(""" + from pytest import hookimpl + from _pytest.debugging import pytestPDB + import os + + @hookimpl(hookwrapper=True) + def pytest_configure(config): + os.environ['PYTHONBREAKPOINT'] = '_pytest._CustomDebugger.set_trace' + yield + assert sys.breakpointhook is not pytestPDB.set_trace + + @hookimpl(hookwrapper=True) + def pytest_unconfigure(config): + yield + assert sys.breakpointhook is sys.__breakpoint__ + os.environ['PYTHONBREAKPOINT'] = '' + """) + testdir.makepyfile(""" + def test_nothing(): pass + """) + @pytest.mark.skipif(not SUPPORTS_BREAKPOINT_BUILTIN, reason="Requires breakpoint() builtin") @pytest.mark.skipif(not _ENVIRON_PYTHONBREAKPOINT == '', reason="Requires breakpoint() default value") def test_sys_breakpoint_interception(self, testdir):