Hi,
When using with pytest, there is a parameter named "snapshot" passed into every def. Where is that parameter coming from? The PyTest example does not contain any "import" commands
Good question! This is part of the pytest "magic". The short answer is that if you install snapshottest, that parameter will automatically be available when you run your tests with pytest. There is no need to import or define anything else!
The longer answer is that pytest uses fixtures as function arguments; if you're not familiar with it and want to learn more, you can read the docs here.
It looks for fixtures in several locations (and so you don't need to import them), a common one being conftest.py. In the case of the snapshottest library, the fixture is defined here and configured so that pytest knows where to look for it.
Hope that helps!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi,
When using with pytest, there is a parameter named "snapshot" passed into every def. Where is that parameter coming from? The PyTest example does not contain any "import" commands
Good question! This is part of the
pytest
"magic". The short answer is that if you installsnapshottest
, that parameter will automatically be available when you run your tests withpytest
. There is no need to import or define anything else!The longer answer is that
pytest
uses fixtures as function arguments; if you're not familiar with it and want to learn more, you can read the docs here.It looks for fixtures in several locations (and so you don't need to import them), a common one being
conftest.py
. In the case of thesnapshottest
library, the fixture is defined here and configured so thatpytest
knows where to look for it.Hope that helps!