python - How can I access a value which is defined in a __init__ function, as a parameter to my test_case -
i have test case data, created in init function. need use parameter test case, unable access test_case_data
class something(object): def __init__(self, logger): #do self.test_case_data = ... #got test case data @pytest.mark.p0 @pytest.parameterize("paramter1, parameter2, .. , ..", test_case_data) def test_something(): #do_something
this code looks like. want use test_case_data parameter, defined in init function.
init isn't run until make instance of class. access:
class classname(object): def __init__(self): self.variable = "value" instance = classname() print(instance.variable)
i'm not sure you're trying here thing remember data members declared in init don't exist until make instance of class.
Comments
Post a Comment