pytest auto-config not correctly created
When I click on the "Run Test" icon on the left side, I expect a config to be created for running that specific test case only. However, the whole file is run. Also, that config is pointing to the wrong file.
For example, when I click on the "Run Test" icon of the highlighted test:

I expect a config that only runs the test "test_jp_story_speaker_init_without_conversation" to be created. However, a config that points to the other file sharing the same name is rather created, according to the args and the results shown.

Please sign in to leave a comment.
Hello,
what version of PyCharm you are running? Please make sure it is up-to-date.
Please disable all custom plugins, go to **File | Settings | Plugins** click the gear icon and choose "Disable all downloaded plugins", to avoid third-party affection.
Second, is is reproducible with a new project and a simple example? If not, please submit an issue at
https://youtrack.jetbrains.com/issues/PY
with a simplified project example and steps to reproduce attached.
Hi Belianskaya,
Thanks for the response in advance. I created a sandbox project and successfully re-created the bug. Here's the steps:
1. Create a project and install pytest
2. Edit config template of "Python tests > Autodetect". Set "Working directory" to project root.
3. Create files with the structure provided below:
4. Create tests with the same name with one passing and one failing, I created them like this:
5. Use "Run tests" for both tests. Both runs will fail while one should pass. You'll see that it's running the same test from the result screen.
The reason I manually set the working directory to my project root is that my pytest fixture is loading files relative to the project root. If I didn't set that, the test won't be able to start because it can't load the files. It's also kinda counter-intuitive that a new testing config is not created/run under the project root directory IMO.
Hello, thank you for the steps I have reproduced the problem and reported as a bug https://youtrack.jetbrains.com/issue/PY-50777 , please follow it for updates.
I apologize for the inconvenience.
Hello,
Could you please try marking the Project Root as Test Sources (right click -> "mark as.." ) instead of editing the Run Configuration template? Will it work for you?