Reputation: 91
How do I make PyCharm take the testing configuration from setup.cfg, a file which was created by PyScaffold?
I did enable PyTest from Settings -> Tools -> Python Integrated Tools -> Testing
What I have until now is a configuration saved in the Python tests section, with:
Target: Script path = C:...\setup.py
Additional arguments: test
But this is what I'm getting when I run it:
[...] ERROR: file not found: test
Or how do I replicate the same testing configuration in PyCharm, as I have in setup.cfg?
console_scripts =
program = program.main:run
[test]
# py.test options when running `python setup.py test`
# addopts = --verbose
extras = True
[tool:pytest]
# Options for py.test:
# Specify command line options as you would do when invoking py.test directly.
# e.g. --cov-report html (or xml) for html/xml output or --junitxml junit.xml
# in order to write a coverage file that can be read by Jenkins.
addopts =
--cov reddit_users_info --cov-report term-missing
--verbose
[...]
testpaths = tests
Upvotes: 1
Views: 1485
Reputation: 584
Open the project directory and configure it to use the venv created. At script path you would have src\program\program.py
,
at parameters you could add -vv
.
Enable PyTest from Settings -> Tools -> Python Integrated Tools -> Testing
Add a run configuration, but add one for testing as well: Edit Configurations -> + -> Python tests -> pytest
.
Run the tests. It will work if you've installed the packages required for testing (check the above "To test" section). The process will create a .coverage file in the project directory.
If you have PyCharm Professional instead of PyCharm Community, you should also do this:
Ctrl + Alt + F6 (Choose coverage suite to display) -> + -> select any of the created files -> Show selected
.
This will add fancy colors in your scripts, depending on where the code is covered by tests.
Upvotes: 3