Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i configure pytest to ignore directories when it's running with --looponfail option?

Tags:

python

pytest

I have a directory with a unittest-module and a logs-directory where debug-informations are written. since I use the -f / --looponfail option, I need changes in the logs-directory to be ignored.

tests$ ls
logs  __pycache__  pytest.ini  test_basic.py

tests$ cat pytest.ini
[pytest]
norecursedirs = logs
python_files = test_*.py

tests$ py.test -h
(...)
[pytest] ini-options in the next pytest.ini|tox.ini|setup.cfg file:

  markers (linelist)       markers for test functions
  norecursedirs (args)     directory patterns to avoid for recursion
  usefixtures (args)       list of default fixtures to be used with this project
  python_files (args)      glob-style file patterns for Python test module discovery
  python_classes (args)    prefixes for Python test class discovery
  python_functions (args)  prefixes for Python test function and method discovery
  addopts (args)           extra command line options
  minversion (string)      minimally required pytest version
  rsyncdirs (pathlist)     list of (relative) paths to be rsynced for remote distributed testing.
  rsyncignore (pathlist)   list of (relative) glob-style paths to be ignored for rsyncing.
  looponfailroots (pathlist) directories to check for changes

Eventually the failing test is invoked in a loop, because changes in logs/test_basic.log are monitored and I wonder why this is so. The documentation seems clear to me.

like image 365
funky-future Avatar asked May 11 '14 22:05

funky-future


2 Answers

looponfailroots now solves this problem. Put this in your setup.cfg:

[tool:pytest]
looponfailroots=mylib
like image 99
Maximilian Avatar answered Sep 30 '22 01:09

Maximilian


pytest-xdist has no option that influences what files are ignored on --looponfail. The norecursedirs only influences what files are collected as tests.

like image 36
hpk42 Avatar answered Sep 30 '22 02:09

hpk42