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

Wouter Overmeire lodagro at gmail.com
Tue Apr 10 00:55:49 PDT 2018

found it .... for item in items: item.callspec.get_param('robot')

2018-04-09 16:29 GMT+02:00 Wouter Overmeire <lodagro at gmail.com>:

> 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/20180410/e45e21b5/attachment.htm>

More information about the testing-in-python mailing list