pycrunch-engine icon indicating copy to clipboard operation
pycrunch-engine copied to clipboard

RF+add nose support

Open yarikoptic opened this issue 4 years ago • 3 comments

  • [x] RF code to avoid code duplication etc across multiple plugins (since no CI, #28; ran locally to get "81 passed, 3 skipped, 10 warnings")
    • [ ] there is more code in pytest plugin directory which seems to be generic and should be moved out
  • [x] actually add nose support (Closes #27)

yarikoptic avatar Oct 17 '20 20:10 yarikoptic

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

yarikoptic avatar Oct 27 '20 17:10 yarikoptic

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

gleb-britecore avatar Mar 17 '21 08:03 gleb-britecore

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)

yarikoptic avatar Mar 17 '21 18:03 yarikoptic