Closed yarikoptic closed 2 years ago
Parsing command-line output can be fragile, it may pick up some unrelated log lines, and in the case of pytest it is also slow (360ms to run pytest.main, and more time to compile bytecode). For each [engine+version], we will need separate parser, and expect that pytest will never change the output format. And, if we have 1000+ tests, it would be overkill to run full discovery every time single file changes
I'm was considering AST as an option, but at the moment of the first release, I didn't have much expertise with it.
This in on a list, but a bit lower than async
support
If deciding what to do next, I would say - async
tests, because it is easy to adjust code for simple discovery
(by removing some top-level import/object instantiation), and not possible at all to run async tests
Re AST, right -- found https://github.com/gleb-sevruk/pycrunch-engine/pull/7/files#diff-950f810bbc146172e4397584f2146599edb7c059f25f2614ad1ccf4166409b05R102 ;-)
re parsing: I bet there should be some way to invoke pytest straight from python to discover tests without running them, and without parsing any stdout.
Will be fixed in https://github.com/gleb-sevruk/pycrunch-engine/pull/57
Fixed! Please give it a shot 🎉
pip install pycrunch-engine==1.3
ATM I am trying to test drive #29 on https://github.com/datalad/datalad/ code base. Output is filled with
which might be something we might want to address on datalad end (to not reuse main loop) but in any case -- I think that pycrunch should not import modules to discover tests. It should either just load those files and inspect via AST or even better -- rely on the underlying engine to discover tests. E.g. with
nose
it should be smth likemay be there is a better way - since in this invocation
nose
also runs all "tests generators" which causes some work to be done in fixtures etc (that is why I explicitly redirected our logging target to /dev/null to not pollute). IMHO for pycrunch purpose "running generators" is not needed probably and those could be considered a single "test".