From 1b50bff6250e64a10132cc8d2354c0a9bf45ee9a Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 19 Apr 2023 14:04:17 -0400 Subject: [PATCH] Error test harness if `--pdb` passed without `-s` --- tests/conftest.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 87611c55..d5b0d697 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -170,6 +170,20 @@ def open_test_pikerd( # https://docs.pytest.org/en/6.2.x/tmpdir.html#the-default-base-temporary-directory print(f'CURRENT TEST CONF DIR: {tmpconfdir}') + conf = request.config + debug_mode: bool = conf.option.usepdb + if ( + debug_mode + and conf.option.capture != 'no' + ): + # TODO: how to disable capture dynamically? + # conf._configured = False + # conf._do_configure() + pytest.fail( + 'To use `--pdb` (with `tractor` subactors) you also must also ' + 'pass `-s`!' + ) + yield partial( _open_test_pikerd, @@ -182,7 +196,7 @@ def open_test_pikerd( # `--ll ` cli flag. loglevel=loglevel, - debug_mode=request.config.option.usepdb + debug_mode=debug_mode, ) # NOTE: the `tmp_dir` fixture will wipe any files older then 3 test