[TIP] pytest - parametrized fixture, skipping tests with marker and order tests

Wouter Overmeire lodagro at gmail.com
Mon Apr 9 07:29:57 PDT 2018


Hi,

Suppose I have to test a robot. the robot will be a fixture and as fixture
setup the robot gets its firmware downloaded. Multiple firmware versions
need to tested.
Assume the robot fixture scope is 'function'. This is not needed based on
the example code (which is a simplification).
Some of the tests can be skipped for some firmware versions. I would like
to do this using a custom marker.

See example code in gihub gist
<https://gist.github.com/lodagro/ae5483215ddd2df791ace7e2d1942318>.

Now I would like to do the following:

- order the test such that a minimal number of firmware downloads are
needed (with the current code, there is a max number of fw downloads,
remember fixture scope needs to be function)
- do not download any firmware that does not have related tests
- implement the skip based on the marker and selected robot firmware


My idea was to do all of this in the pytest_collection_modifyitems method.
I found how I can access the marker for each item, but not how can I access
robot fixture firmware? So do I need another approach or is it possible to
access the robot fixture for each item from pytest_collection_modifyitems ?

Thanks,

Wouter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20180409/5e8d272c/attachment.htm>


More information about the testing-in-python mailing list