How do I replicate the same testing configuration in PyCharm, as I have in setup.cfg?

I did enable PyTest from `Settings -> Tools -> Python Integrated Tools -> Testing`

setup.cfg was created by PyScaffold

This is what 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

How do I replicate these settings in a PyCharm testing configuration?

 

2 comments

Solution: after creating and activating the venv, run this:

python setup.py develop

Or this: 

pip install -e .

Then: 

1. Open the project directory and configure it to use the venv created.

2. Enable PyTest from `Settings -> Tools -> Python Integrated Tools -> Testing`

3. Add a run configuration, but add one for testing as well: `Edit Configurations -> + -> Python tests -> pytest`

4. Run the tests. The process will create .coverage in the project directory.
`Ctrl + Alt + F6 (Choose coverage suite to display) -> + -> select .coverage -> Show selected`.
This will add fancy colors in your scripts, depending on where the code is covered by tests.

TODO: make PyCharm understand that certain files/directories are excluded from coverage,
because right now it shows me "0% files, not covered" for directories like venv and tests.

 

But now, how do I make PyCharm understand that certain files/directories are excluded from coverage? 
Because right now it shows me "0% files, not covered" for directories like venv and tests.

0

Please sign in to leave a comment.