Cannot evaluate expressions in debugger console when pytest is running with -n

If debugging a test normally (with pytest as default test runner) I can evaluate expressions in the console just fine. However, if running with -n (multiprocessed), I can't evaluate any outputs directly.

Is there a way around this, while still letting pytest read the pytest.ini file?

7 comments
Comment actions Permalink

Hi, could you please provide a pytest.ini sample and a screenshot of your run/debug configuration? 

I will try to reproduce the issue locally.

0
Comment actions Permalink

The ini file only contains

addopts = -n auto -m "not integration"

My debug configuration is just the auto-generated config when clicking the arrow of a pytest-compatible function in PyCharm.

0
Comment actions Permalink

I get:

pytest: error: unrecognized arguments: -n auto

Probably requires additional setup. Could you provide your `pip freeze` output?

0
Comment actions Permalink

Additional testing plugins:

pytest==6.2.4
pytest-cov==2.12.1
pytest-forked==1.3.0
pytest-sugar==0.9.4
pytest-xdist==2.2.1
testpath==0.5.0

 

0
Comment actions Permalink

Thank you,

Trying reproduce the issue now, but it seems to work fine for me with a minimal code.

Could you show a minimal code snippet and steps to reproduce the issue?

0
Comment actions Permalink

Even a simple file like

test_test.py

with the added code

def test_that_this_works():
foo = 1

and then run in the debugger will trigger the multiprocessing worker from pytest.ini.

I've not found a way to setup the default Debug context configuration with options to ignore/use different parameters. Otherwise I'd have to specifically create a configuration for every test file (and there are lots).

Running a test starts:

Launching pytest with arguments .../test_test.py --no-header --no-summary -q in .../test

============================= test session starts ==============================
gw0 I / gw1 I / gw2 I / gw3 I / gw4 I / gw5 I / gw6 I / gw7 I
[gw0] darwin Python 3.9.4 cwd: .../test
[gw1] darwin Python 3.9.4 cwd: .../test
[gw2] darwin Python 3.9.4 cwd: .../test
...

[gw0] Python 3.9.4 | packaged by conda-forge | (default, May 10 2021, 22:13:15) -- [Clang 11.1.0 ]
[gw1] Python 3.9.4 | packaged by conda-forge | (default, May 10 2021, 22:13:15) -- [Clang 11.1.0 ]
[gw2] Python 3.9.4 | packaged by conda-forge | (default, May 10 2021, 22:13:15) -- [Clang 11.1.0 ]
...

gw0 [1] / gw1 [1] / gw2 [1] / gw3 [1] / gw4 [1] / gw5 [1] / gw6 [1] / gw7 [1]

scheduling tests via LoadScheduling

test_test.py::test_that_this_works
0

Please sign in to leave a comment.