3535unpicklable_function  =  lambda : None 
3636
3737
38- @pytest .fixture (scope = "module" ) 
3938def  model_cases ():
4039    class  TestHparamsNamespace :
4140        learning_rate  =  1 
@@ -93,9 +92,9 @@ class TestModel7:  # test for datamodule w/ hparams w/ attribute (should use dat
9392    return  model1 , model2 , model3 , model4 , model5 , model6 , model7 
9493
9594
96- def  test_lightning_hasattr (tmpdir ,  model_cases ):
95+ def  test_lightning_hasattr (tmpdir ):
9796    """Test that the lightning_hasattr works in all cases.""" 
98-     model1 , model2 , model3 , model4 , model5 , model6 , model7  =  models  =  model_cases 
97+     model1 , model2 , model3 , model4 , model5 , model6 , model7  =  models  =  model_cases () 
9998    assert  lightning_hasattr (model1 , "learning_rate" ), "lightning_hasattr failed to find namespace variable" 
10099    assert  lightning_hasattr (model2 , "learning_rate" ), "lightning_hasattr failed to find hparams namespace variable" 
101100    assert  lightning_hasattr (model3 , "learning_rate" ), "lightning_hasattr failed to find hparams dict variable" 
@@ -112,9 +111,9 @@ def test_lightning_hasattr(tmpdir, model_cases):
112111        assert  not  lightning_hasattr (m , "this_attr_not_exist" )
113112
114113
115- def  test_lightning_getattr (tmpdir ,  model_cases ):
114+ def  test_lightning_getattr (tmpdir ):
116115    """Test that the lightning_getattr works in all cases.""" 
117-     models  =  model_cases 
116+     models  =  model_cases () 
118117    for  i , m  in  enumerate (models [:3 ]):
119118        value  =  lightning_getattr (m , "learning_rate" )
120119        assert  value  ==  i , "attribute not correctly extracted" 
@@ -132,9 +131,9 @@ def test_lightning_getattr(tmpdir, model_cases):
132131            lightning_getattr (m , "this_attr_not_exist" )
133132
134133
135- def  test_lightning_setattr (tmpdir ,  model_cases ):
134+ def  test_lightning_setattr (tmpdir ):
136135    """Test that the lightning_setattr works in all cases.""" 
137-     models  =  model_cases 
136+     models  =  model_cases () 
138137    for  m  in  models [:3 ]:
139138        lightning_setattr (m , "learning_rate" , 10 )
140139        assert  lightning_getattr (m , "learning_rate" ) ==  10 , "attribute not correctly set" 
0 commit comments