The --ignore-glob option allows to ignore test file paths based on Unix shell-style wildcards. If you want to exclude test-modules that end with _01.py , execute pytest with --ignore-glob='*_01.py' .
With no arguments, pytest looks at the current working directory (or some other preconfigured directory) and all subdirectories for test files and runs the test code it finds. Running all test files in the current directory. We can run a specific test file by giving its name as an argument.
Disabling warnings summary Although not recommended, you can use the --disable-warnings command-line option to suppress the warning summary entirely from the test run output.
py.test --ignore=somedir
worked for me
If you have several directories with different parents you can specify different --ignore
parameters:
py.test --ignore=somedir --ignore=otherdir --ignore=etcdir
- new option: --ignore will prevent specified path from collection.
Can be specified multiple times.
I solved the mystery: If a pytest section is found in one of the possible config files (pytest.ini
, tox.ini
and setup.cfg
), pytest will not look for any others so be sure you define the py.test options in a single file.
I would suggest using setup.cfg
.
You can use
py.test -k 'not third'
that excludes all 'third' directory contents.
In my case, the issue was the missing wildcard. The following works for me:
[tool:pytest]
norecursedirs = subpath/*
whereas just norecursedirs = subpath
didn't.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With