Configure PyCharm so that "Run Test" works
Currently "Run Test" (the green play button by each test)

triggers
/Users/dario.figueira/miniconda3/envs/decant_imaging/bin/python /Users/dario.figueira/Library/Application Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/231.8109.197/PyCharm.app/Contents/plugins/python/helpers/pycharm/_jb_pytest_runner.py -- /Users/dario.figueira/miniconda3/envs/decant_imaging/lib/python3.8/test/__init__.py::
Testing started at 14:26 ...
Launching pytest with arguments /Users/dario.figueira/miniconda3/envs/decant_imaging/lib/python3.8/test/__init__.py:: --no-header --no-summary -q in /Users/dario.figueira/Work/decant_imaging
============================= test session starts ==============================
collecting ... collected 0 items
============================ no tests ran in 0.01s =============================
ERROR: not found: /Users/dario.figueira/miniconda3/envs/decant_imaging/lib/python3.8/test/__init__.py::
(no name '/Users/dario.figueira/miniconda3/envs/decant_imaging/lib/python3.8/test/__init__.py::' in any of [<Package test>])
Process finished with exit code 4
Empty suite
Instead of actually running the test.
Workaround: "Edit configurations..."

and setting "Target:" to "Module name", and paste in the module name

How to make it so just clicking the green arrow Run Test will work for any test?
请先登录再写评论。
Hi Andrey Resler
Here https://github.com/WurmD/MWE-tests
1. Set Default test runner to pytest
2. Right click the green arrow besides `def test_string_produced():`
yields:
Thank you,
The sample works for me out of the box. Do you have these checkboxes enabled in your run/debug configuration?
Yes
and it is also set in the template
To be doubly sure Andrey Resler, you clicked *this* green play button, and the test ran?
Actually, PyCharm should create a temporary configuration with module path automatically. Are you using the latest PyCharm version by any chance?
https://www.jetbrains.com/pycharm/download/
If the issue is reproduced in the latest version, please also go to **Preferences | Tools | Python Integrated Tools** and try setting default test runner to pytest.
Does it help?
Now in latest version
PyCharm 2023.1 (Professional Edition)
Build #PY-231.8109.197, built on March 29, 2023
Licensed to Ocado Innovation Ltd
Runtime version: 17.0.6+10-b829.5 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.3.1
GC: G1 Young Generation, G1 Old Generation
Memory: 6144M
Cores: 16
Metal Rendering is ON
Clicking the gutter icon "play" yields the same faulty behaviour
Default test runner was already set to pytest
To restore default settings, you can use **File | Manage IDE settings | Restore Default Settings...**. Your current settings will be backed up, so you can revert to them later if needed (to do this, just import settings from the backed up folder).
:confused:
With Default Settings my PyCharm is in a broken state:
it does not analyse the files, it's continuously starting analysing and stopping
And thus, since it doesn't analyse, the gutter icon "play" does not show up.
What now?
https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html
Nop :( same behavior with Default Configurations
So you can't reproduce, and the issue persists with default configurations here and default test runner set to pytest
Is this a Mac issue? Can you test with a Mac?
Hi!
Are there any updates on this issue? I just got exactly the same problem when I upgraded PyCharm from version 2023.2.2 to 2023.3.3. I'm also using MacOs.
What's happening? We're paying, why are we not getting support?
Support, would you please test in a Mac?
I managed to solve the issue by marking the test folder as “Test” and the source folder as “Source” in Settings -> Project -> Project Structure. It seems that when you have a directory in “Source” with the same name as a directory in “Tests”, the run configuration chooses the wrong directory for the tests if you don't explicitly set the test-source distinction.
What should I see here?
Should the `src` folder be automatically assigned to “Sources”, and `test` be automatically assigned to “Tests”?
So first you select your “test” directory on your tree structure and then click on the button “Tests” on the upper bar that says “Mark as:”. Do a similar process with the “src” directory marking it as “Sources”. This was apparently not set up automatically.
Assigning `src` folder to “Sources”, and `test` to “Tests” solved it for me