jeudi 28 mai 2015

pytest: how to ignore metafunc parameterize values for few tests in a class

I have a test written in python using pytest. which has conftest.py for setup, which parameterize 5 account ids for each test. The Test Class has total 5 tests, out of which 4 needs the tests to be parameterized using metafunc (Which i have done in conftest.py), the remaining 1 test need not be parameterized. please tell how to run all these tests in one go with avoiding parameterization for the last test (test5).

my conftest.py has the following;

def pytest_generate_tests(metafunc):
        accid = ['string1','string2','string3','string4','string5']
        metafunc.parametrize("accid", accid)

my test file is named test_accid.py; which has the following;

    class TestAccount:
        def test_base1(self, accid):
            <test code>
        def test_base2(self, accid):
            <test code>
        def test_base3(self, accid):
            <test code>
        def test_base4(self, accid):
            <test code>

        #The following test should not have accid
        def test_no_accid(self):
            <test code>

Aucun commentaire:

Enregistrer un commentaire