can I specify which test files to run in .coveragerc?

Viewed 142

My file structure is below,

Logic
--packageA
----file1
----file2
--packageB
----file3
----file4
--tests
----testfile1
----testfile2
----testfile3
--.coveragerc

I'd like to include packageA only for tests, and run testfile1 and testfile2 to measure the coverage.

testfile3 is for packageB.

So I wrote my .coveragerc file,

[run]
branch = True
include = /packageA/*
omit = *tests*

and, when I run coverage with command coverage run --rcfile=../.coveragerc -m pytest in directory tests, it tries running testfile3 as well.

How can I run testfile1 and testfile2 with .coveragerc configuration?

1 Answers

You can use the [run] command_line option to set the command line to use when you run coverage run. But coverage isn't trying to be a general runner. You might want a shell script, a Makefile, or a tox.ini file instead.

Are you typing the coverage run --rcfile=../.coveragerc -m pytest command by hand?

Related