PyCharm/Testing/How To/Run All Pytest Tests in One Directory inside a Python Monorepo
Properties
- tags
- PyCharm, Diataxis/How To
How To Run All Pytest Tests in One Directory inside a Python Monorepo with PyCharm
Goal
Preconditions
Procedure
1. Mark Source Roots with PyCharm/Tool/Project/Right Click/Mark Directory As/Sources Root
2. Tell PyCharm to Use pytest with PyCharm/Settings/Tools/Python Integrated Tools/Testing
Settings ▶ Tools ▶ Python Integrated Tools
Testing → Default test-runner pytest.
Apply/OK.
3. Create a PyCharm/Run Configuration for the Directory
Top-right toolbar → Add Configuration…
+ → Python tests ▶ pytest.
Name:
tests-app_a.Target → choose Folder and select
apps/app_a/tests.Working directory → set to the monorepo root (crucial so relative imports &
pytest.iniare found).(Optional) Additional args:
4. (Optional) Save as a Template
5. Verify Discovery
Troubleshooting
References