I'm trying to iterate a pytest test over a list of values which i generate inside another method in the test class.
The problem is that i get: "@pytest.mark.parametrize("number",TestScratch.list_testing) NameError: name 'TestScratch' is not defined" error when i try to run.I know for a fact that when i pass the list as a hard coded list i.e [0,3,54,90] it works. Below is my code :
class TestScratch(object):
@classmethod
def setup_class(cls):
cls.list_testing = []
@classmethod
def setup_method(cls):
pass
def test_populate_list(self):
for i in range(100):
self.list_testing.append(i)
@pytest.mark.parametrize("number",TestScratch.list_testing)
def test_pytest_param(self, number):
assert type(number) == int
@classmethod
def teardown_class(cls):
'''
pass
'''
I also tried self.class.list_testing but i get the same error
Environment details:
Python: 3.6.8
Pytest: 5.2.1