Fixture metadata available during collection / How do parametrized fixtures work? #14281
Replies: 1 comment
-
|
Quick idea which will mostly keep your current setup. Add a There are various other solutions, but maybe this gets you going.
Currently, not really. Nothing built-in at least, I'm sure there's some plugin which does it :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I would appreciate a bit of guidance.
Context
I have a lot of data processing tests that I want to run against real data.
The data are in total potentially quite big (>100GB), so I don't have them checked out in the workdir, instead I store them in DVC (https://dvc.org/), but it could just as well be Git LFS.
I want to create a pytest plugin that transparently downloads the files on disk before running the tests.
There are also a lot of unrelated data files in my repo, so I don't want to download all the files upfront.
The simplest solution would be to download the files during fixture setup for each test, but that doesn't perform well. My files are in object storage and it is important to download them in parallel.
Ideally, I would like to
pytest tests/etl/ -m "dvc" -k processingSo I mark each test with the set of files it needs, and in a session-scope autouse fixture I collect needed files from each marked test and download it.
All good.
But often these files are needed for some mock, e.g. for testing ETL pipelines
in which case, I would have add the mark to each test using the fixture.
Ideally, if I select a test that uses the
mock_clientfixture, I would like to add the files needed formock_clientto the list of files that I need to download.My question
Is there some way to add metadata to the fixtures that will be accessible at collection time?
I came across this thread #11462, where the verdict is "to track your metadata in some way unrelated to the pytest internals", which is very reasonable.
On the other hand, pytest supports parametrized fixtures
and these parameters show up in the collected tests, so apparently they must be available during collection!
How does this work? Does it use some mechanism that I could potentially also use?
Thank you very much for answers.
Beta Was this translation helpful? Give feedback.
All reactions