Anshul Gupta <anshul.gu...@riverbed.com> writes: > Hi, > > I am new to the pytest and still exploring it. I have been searching > extensively for data driven testing modules provided by pytest but could not > find anything substantial for it. I did came across that using parametrize > it can be done but when I am trying to pass data from fixture to the > pytest.mark.paramaetrize it does not accept it, below it the small snippet > that I am doing. > > @pytest.fixture > Def data(): > Return data > > @pytest.mark.parametrize(“input”,data): > Def test_ddt(input): > Print input > > Executing it says that NameError: name 'data' is not defined
Hi, import pytest @pytest.fixture def data(): return ("data", ) @pytest.mark.parametrize("input", data()) def test_ddt(input): print input is working for me, but I guess the better way is either @pytest.fixture(params=("data", )) def data(request): return request.param def test_ddt(data): print data or perhaps @pytest.mark.parametrize("input", ("data", )) def test_ddt2(input): print input Regards, Berthold > > Please do let me know what is the most appropriate and efficient way >of achieving data driven testing using pytest. > > Thanks in advance!! > > Regards, > Anshul > _______________________________________________ > Pytest-dev mailing list > Pytest-dev@python.org > https://mail.python.org/mailman/listinfo/pytest-dev
pgpLMGiunKL5k.pgp
Description: PGP signature
_______________________________________________ Pytest-dev mailing list Pytest-dev@python.org https://mail.python.org/mailman/listinfo/pytest-dev