Pycharm unable to run single parameterized test from selection.
Answered
Thank you for amazing Pycharm.
I am able to run py.tests setup. While running, I would want to debug only one test out of all the tests.
However my test is parameterized and there is no option to run single test of all of them:
Please find attached screenshot.
test_filter_basic has 11 tests. I want to debug only one test. Is there a way I can modify the Pycharm source code and add this feature myself? It would help a lot!!
Please sign in to leave a comment.
Hello. Please track https://youtrack.jetbrains.com/issue/PY-16316
Since PyCharm now uses TC runners, you also may track https://github.com/JetBrains/teamcity-messages/issues/121 and vote for it.
Thank you for using PyCharm.
Hello.
Running concrete parametrized instance is not supported for now. In next version we will improve and document API to make it user-accessible, but we only can implement it if py.test itself supports this scenario. Does it?
Hi Ilya Kazakevich,
Thank you for the reply.
Py.test does support executing one test case.
py.test "query_planner/test_ast.py::TestASTMeasuresNoGroupBy::()::test_ast_basic1[measures0-exp_measure_types0]"
for class TestASTMeasuresNoGroupBy:
@pytest.mark.parametrize("measures, exp_measure_types",testdata)
def test_ast_basic1(self, measures, exp_measure_types):
similar for
@pytest.mark.parametrize("filter_id", list(range(12)))
def test_filter_basic1(self, filter_id):
py.test "query_planner/test_ast.py::TestASTSimpleFilters::()::test_filter_basic1[0]"
Let me know if I could help in any way.
Thanks!!
Hi Ilya Kazakevich
How it's going on the way to implement this issue ???
So 4 (four) years have passed since the question was posted !!!
REALLY annoying :(
Thinking to roll out to VS Code...
Hello Dharmagetic,
I believe this is already implemented for pytest. Could you please check?
Hello Ilya Kazakevich
Seems it's doesn't work
I'm running Pytest for single Django test as described in https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000491790-Using-Pytest-with-Django
This single test decorated with @parameterized.expand
WARNING !!!
This decorator exists in https://pypi.org/project/parameterized/ packed, but it is not originall pytest's fixture
And finally I'm getting:
ERROR: not found: "path/to/test"
Process finished with exit code 4
Empty suite
Can Pycharm support https://pypi.org/project/parameterized/ package ?
Hello.
This is a different probklem, unfortunately. Please, create an issue
https://youtrack.jetbrains.com/newIssue?project=PY
Hi JetBrains - any update on this - we have many a long running test where each parametrized test takes about 30 seconds - so waiting to go through 8 passing tests to get to the parametrized test that you want to test it a big bother.
And someone from my team just showed that VScode is able to do this - so it is definitely possible.
Can you give a time-frame on when you will fix this (rather basic) feature?
PyCharm does indeed have this feature but it seems to only work if your parameters do not contain dots (either float number or in string). I created a new bug report for it: https://youtrack.jetbrains.com/issue/PY-56894/Pycharm-unable-to-run-single-parameterized-pytest-test-from-selection-when-there-is-a-dot-in-parameter-value
Ahh - so that is why nobody else hit the bug - out patameters also contain dots.
Hit the same issue but I run unittests
https://youtrack.jetbrains.com/issue/PY-56683/Running-a-single-test-using-parameterized-decorator-within-PyCharm-fails-with-Empty-suite
If you add the main, it will be empty if you run a particular test.
```
raise TypeError("don't know how to make test from: %s" % obj)
TypeError: don't know how to make test from: None
```
The value passed to unit test load
loadTestsFromNames(self, names, module=None):
['tests_my_test.TestsMyTestets.test_with_parameterized'] ←