I have multiple tests written in the following format. When the test is run, why do some tests fail with exception AttributeError: 'TestMyTest' object has no attribute 'var1'
?
var1
is defined as class variable in test_init()
. Still the exception is thrown in test_1()
.
@pytest.fixture(scope="module")
def do_setup(run_apps):
"""
Do setup
"""
# Do something
yield some_data
class TestMyTest(BaseTestClass):
ids = dict()
task_id = list()
output_json = None
def test_init(self, do_setup):
TestMyTest.var1 = Feature1()
def test_1(self):
self._logger.info("self.var1: {}".format(self.var1))