2

Considering the following snippet:

import pytest @pytest.mark.parametrize("a, b", [ (1, 1), (2, 2), (2, 3) ]) def test_eq(a, b): assert a == b 

Now this creates three (trivial) tests. Now during debugging I notice the third test fails. How would I tell pycharm to rerun the third test configuration (in debugging mode)? right clicking on this test run in the ide only shows me a context menu to rerun the whole test_eq test set.

1 Answer 1

4

I'm pretty sure you can not do that. The different tests are created only when the decorator runs, and that happens when the module where these tests are defined is executed. In other words: when you run the tests.

As long as you are looking at the code in PyCharm (or any other editor for that matter), that has not yet happened. And PyCharm does not (can not) know that this one test function actually results in three different test cases.

If you really need to run the test with only selected values of the parameters, and you have the source code available, the easiest way is probably to just comment out the parameter values that you don't want to use. Like:

@pytest.mark.parametrize("a, b", [ # (1, 1), # (2, 2), (2, 3) ]) def test_eq(a, b): assert a == b 

Later, when you resolved the issue, you can then uncomment these lines again.

Sign up to request clarification or add additional context in comments.

1 Comment

Well it's not "that simple" in my case: the test are generated, and somewhere for a seemingly normal set of parameters it fails the 10th test. Sure I could extract those parameters and first write an explicit test. Possible but quite a bit of work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.