tarpas / pytest-testmon

Selects tests affected by changed files. Executes the right tests first. Continuous test runner when used with pytest-watch.
https://testmon.org
MIT License
823 stars 55 forks source link

How does testmon handle data files? #178

Open uriva opened 2 years ago

uriva commented 2 years ago

if I have in my code an open('path/to/file.json').read() command, would testmon be able to flag that file?

I saw there is something called file tracers in coverage but not sure if it is for this use case.

tarpas commented 2 years ago

No, testmon wouldn't be able to recognize file.json as a dependency of the code.

AFAIK coverage is and will always deal with executable files and lines but not I/O.

https://coverage.readthedocs.io/en/6.0.2/api_plugin.html#file-tracers can be implemented but they are intended for things like yml file with instructions or django templates...

There are a couple of possible solutions for your use case but all the realistic ones include manual declaration of the dependency of tests to input files.