@@ -23,7 +23,7 @@ class TestConfigModule(TestCase):
2323 def tearDown (self ):
2424 # Config changes get persisted between test cases
2525 for k in config ._config :
26- config ._config [k ].user_override . set ( _UNSET_SENTINEL )
26+ config ._config [k ].user_override = _UNSET_SENTINEL
2727 config ._hash_digest = None
2828 # Reset deprecation warning flags
2929 for k in config ._config :
@@ -86,7 +86,7 @@ def test_none_override_semantics(self):
8686 config .e_bool = None
8787 self .assertIsNone (config .e_bool )
8888 for k in config ._config :
89- config ._config [k ].user_override . set ( _UNSET_SENTINEL )
89+ config ._config [k ].user_override = _UNSET_SENTINEL
9090
9191 def test_reference_semantics (self ):
9292 config .e_list .append (2 )
@@ -157,42 +157,6 @@ def test_save_config(self):
157157 self .assertTrue (config .e_bool )
158158 self .assertFalse (config .e_ignored )
159159
160- def test_save_config_with_patch (self ):
161- self .assertTrue (config .e_bool )
162- with config .patch (e_bool = False ):
163- p = config .save_config ()
164- self .assertDictEqual (
165- pickle .loads (p ),
166- {
167- "_cache_config_ignore_prefix" : ["magic_cache_config" ],
168- "e_bool" : False ,
169- "e_dict" : {1 : 2 },
170- "e_float" : 1.0 ,
171- "e_int" : 1 ,
172- "e_list" : [1 ],
173- "e_none" : None ,
174- "e_set" : {1 },
175- "e_string" : "string" ,
176- "e_tuple" : (1 ,),
177- "nested.e_bool" : True ,
178- "_e_ignored" : True ,
179- "e_compile_ignored" : True ,
180- "magic_cache_config_ignored" : True ,
181- "_save_config_ignore" : ["e_ignored" ],
182- "e_config" : True ,
183- "e_jk" : True ,
184- "e_jk_false" : False ,
185- "e_env_default" : True ,
186- "e_env_default_FALSE" : False ,
187- "e_env_default_str" : "1234" ,
188- "e_env_default_str_empty" : "" ,
189- "e_env_force" : True ,
190- "e_optional" : True ,
191- "e_deprecated" : True ,
192- "e_not_deprecated" : False ,
193- },
194- )
195-
196160 def test_save_config_portable (self ):
197161 with warnings .catch_warnings ():
198162 warnings .filterwarnings ("ignore" , category = FutureWarning )
@@ -444,7 +408,7 @@ def test_bad_jk_type(self):
444408 AssertionError ,
445409 msg = "AssertionError: justknobs only support booleans, thisisnotvalid is not a boolean" ,
446410 ):
447- _ConfigEntry (Config (default = "bad" , justknob = "fake_knob" ), "test" )
411+ _ConfigEntry (Config (default = "bad" , justknob = "fake_knob" ))
448412
449413 def test_alias (self ):
450414 self .assertFalse (config2 .e_aliasing_bool )
@@ -464,15 +428,13 @@ def test_reference_is_default(self):
464428 def test_invalid_config_int (self ):
465429 with self .assertRaises (AssertionError ):
466430 _ConfigEntry (
467- Config (default = 2 , env_name_default = "FAKE_DISABLE" , value_type = int ),
468- "test" ,
431+ Config (default = 2 , env_name_default = "FAKE_DISABLE" , value_type = int )
469432 )
470433
471434 def test_invalid_config_float (self ):
472435 with self .assertRaises (AssertionError ):
473436 _ConfigEntry (
474- Config (default = 2 , env_name_force = "FAKE_DISABLE" , value_type = float ),
475- "test" ,
437+ Config (default = 2 , env_name_force = "FAKE_DISABLE" , value_type = float )
476438 )
477439
478440 def test_deprecated_config (self ):
@@ -560,49 +522,6 @@ def fn(x):
560522 f"Unexpected config deprecation warnings: { [str (x .message ) for x in deprecation_warnings ]} " ,
561523 )
562524
563- def test_patch_then_global (self ):
564- self .assertTrue (config .e_bool )
565- with config .patch (e_bool = False ):
566- self .assertFalse (config .e_bool )
567-
568- config .e_bool = False
569- self .assertFalse (config .e_bool )
570-
571- def test_is_default_patch (self ):
572- self .assertTrue (config .e_bool )
573- with config .patch (e_bool = False ):
574- self .assertFalse (config ._is_default ("e_bool" ))
575-
576- def test_dict_patch (self ):
577- self .assertTrue (config .e_bool )
578- with config .patch (e_bool = False ):
579- d = config ._get_dict ()
580- self .assertFalse (d ["e_bool" ])
581-
582- def test_set_in_patch (self ):
583- self .assertEqual (config .e_int , 1 )
584- with config .patch (e_int = 2 ):
585- self .assertEqual (config .e_int , 2 )
586- config .e_int = 3
587- self .assertEqual (config .e_int , 3 )
588- # Exiting the patch resets e_int to 1, losing the fact that we explicitly set it to 4 - see ConfigModule._do_setattr
589- self .assertEqual (config .e_int , 1 )
590-
591- def test_nested_patch (self ):
592- self .assertEqual (config .e_int , 1 )
593- self .assertEqual (config .e_string , "string" )
594- with config .patch (e_int = 2 , e_string = "inner" ):
595- self .assertEqual (config .e_int , 2 )
596- self .assertEqual (config .e_string , "inner" )
597- with config .patch (e_int = 3 ):
598- self .assertEqual (config .e_int , 3 )
599- self .assertEqual (config .e_string , "inner" )
600- config .e_int = 4
601- self .assertEqual (config .e_int , 4 )
602- self .assertEqual (config .e_int , 2 )
603- self .assertEqual (config .e_int , 1 )
604- self .assertEqual (config .e_string , "string" )
605-
606525
607526if __name__ == "__main__" :
608527 run_tests ()
0 commit comments