DSGN: collect tests metainfo during execution #5640
Labels
topic: parametrize
related to @pytest.mark.parametrize
type: performance
performance or memory problem/improvement
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
Uh oh!
There was an error while loading. Please reload this page.
As stated here collection of all metadata happens before tests are actually executed. This leads to performance issues that makes pytest parametrization hard to use for at least following 2 reasons:
Consider example: we want to parametrize test over array with say 10 parameters. Pytest easily deal with this creating all possible permutations from 10. But if now we need all permutations for 2 levels - we need 10 times more tests and 10 more RAM? What if we need more (in fact it is not just intentionally created test - its from real life problem; if we test function with 2-3 nested conditions and maybe nested 2-3 function calls inside we already need about 4-9 level in order to hit each situation possible). In fact even 4-5 levels (i.e. maximum is 4-5 level for nested condition possible) with 20GB RAM already not feasible (but this info from my concrete case of course).
-x
mark to pytest parameters? Answer is we may wait for 3-5 min for metadata being collected and right after that we may fail on the 1st test. But even if we not - one almost never need all this bunch of metainfo - only the failed ones (which count usually much lesser than all input tests count), i.e. we not even need to collect metainfo before - we even not need majority of it collected anyhow (lazily or not; at least not all of it).And yes, I saw comment in mentioned issues about design problem, etc. Just get another ping in order to remind that without collecting metadata and treating iterators lazily pytest is not scalable.
In order to bring some thoughts here (cause redesign is always really hard and maybe here are some workarounds as well) maybe follow-ups might be somehow internally reimplemented for iterators without need to do major rewriting:
For now I am using some workaround like this:
So I'm still parametrizing fixture but over "indexes" and just in order to say pytest how many times do retest with new data. It's ugly but for now it works) Also need somehow knew count of generated data (but if we exceed this count - just will get pytests fails with
StopIteration
error which might be marked as passed).Another approach is to use fixtures as factories - but here as I understand we will iterate over data inside test, so for pytest it will be as single test which is not good.
And last what I've devised here for now is to use
pytest.main()
in loop. Something like so:The text was updated successfully, but these errors were encountered: