I am reading my test data from a Python file as follows.
//testdata.py -- its a list of sets.
TEST_DATA = [
(
{"test_scenario":"1"}, {"test_case_id":1}
),
(
{"test_scenario":"2"}, {"test_case_id":2}
)
]
Now I use this test data as part of a pytest test file.
// test.py
// import testdata
test_data = testdata.TEST_DATA
start = 0
class TestOne():
@pytest.mark.parametrize(("test_scenario,testcase_id"),test_data)
@testcaseid.marktc[test_data[start][1]["test_case_id"]]
def testfunction():
global start
start = start + 1
// Doing test here.
Now when I print start, it changes its value continuoulsy. But when I try to retrieve the pytest results, I still keep getting start = 0 due to which my test case ID isnt being recorded properly.
Can I either
- Pass marker from within the function.
- Or is there a way to change the count of start dynamically in this example?
P.S. This is the best way that I am able to store my test data currently.
Here's how i have my testcaseid.marktc defined. // testrailthingy.py
class testcaseid(object):
@staticmethod
def marktc(*ids):
return pytest.mark.testrail(ids=ids)