[TIP] pytest skipif marker with fixtures
holger krekel
holger at merlinux.eu
Thu Dec 12 23:30:43 PST 2013
Hello Christian, Bruno,
Bruno is right about how you currently need to do it.
Maybe it's worth to consider an enhancement issue that one
can use fixtures in skipif/xfail markers conditions
directly. Feel free to file one at
https://bitbucket.org/hpk42/pytest/issues/new
Not sure right now what the syntax should be, though.
best,
holger
On Thu, Dec 12, 2013 at 17:04 -0200, Bruno Oliveira wrote:
> Hello Christian,
>
> >From the documentation at
> http://pytest.org/latest/skipping.html#imperative-xfail-from-within-a-test-or-setup-function,
> I think you will have to skip the test from inside the test method:
>
> # product is the fixture instanciated by the plugin
> import pytest
> class TestMyProduct:
> def test_product_name(self, product):
> if product.name != 'blabla':
> pytest.skipif('product name is blabla')
> assert name == 'blabla'
>
> Hope this helps,
> Cheers,
>
>
> On Thu, Dec 12, 2013 at 4:37 PM, Christian Staffa
> <Christian.Staffa at gmx.de>wrote:
>
> >
> > Hi all on the list :)
> >
> > Well, I am writing here a test with the pytest framework.
> > I got started to write me a own plugin for my testing environment.
> > This plugin generates a fixture on session level.
> > Now I write a test and define a testfunctiont which uses my fixture being
> > instanciated by the plugin....
> > But I want to use a skipif marker when a certain condition is given
> > produced by the plugin fixture.
> > How can i achieve that? Any ideas? is it possible?
> >
> > Enough story... here is an example in essence:)
> >
> > # file: testfile.py
> > # product is the fixture instanciated by the plugin
> > import pytest
> > class TestMyProduct:
> > pytest.skipif(product.name != 'blabla')
> > def test_product_name(self, product):
> > print product.name
> > assert name == 'blabla'
> >
> > Thanks for any comments :)
> >
> > Chris
> >
> >
> >
> > _______________________________________________
> > testing-in-python mailing list
> > testing-in-python at lists.idyll.org
> > http://lists.idyll.org/listinfo/testing-in-python
> >
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
More information about the testing-in-python
mailing list