gleb-sevruk / pycrunch-engine

NCrunch inspired tool for continuous testing Python
https://pycrunch.com
Other
57 stars 8 forks source link

RF+add nose support #29

Open yarikoptic opened 3 years ago

yarikoptic commented 3 years ago
yarikoptic commented 3 years ago

Merged #30 into this PR. Yet to see if works for primary target use case (datalad) probably primarily due to datalad's issue https://github.com/datalad/datalad/issues/5100 . I guess I might need to try it on some simpler project first

gleb-britecore commented 3 years ago

I did some digging and tried to implement AST discovery. Everything was fine until I had to find a class inheritance tree; AdvancedScenario -> AdvancedTestCase -> AbstractTestCase -> TestCase; AST shows only 1 level of inheritance.

So I started wondering how pytest (and nose) works, and it is a combination of Module import and AST rewrite image

So, as a surprise for me, they actually run all the code (such as sleep(10)) before the test method execution; and that is not different from SimpleTestDiscovery;

The problem you are facing can be masked with nest-asyncio as described in this answer: https://stackoverflow.com/a/56434301/2377370

import nest_asyncio
nest_asyncio.apply()

pycrunch-engine opens asyncio loop at the startup, so code previously working in synchronous test runner might fail.

I put a 2-liner patch in both engine venv/datalad/lib/python3.7/site-packages/pycrunch/main.py and child runtime multiprocess_child_main.py and was able to run some of the tests from your project: image

Not sure where to go from here, but I thought it might be interesting, cc @yarikoptic

yarikoptic commented 3 years ago

yeah, async fiasco we are still fighting: seems to be a big design blow to any python programmer due to alleniating async code from non-async ;-) (nest_asyncio is just a workaround)