def test_overlay(): t = VariableTracking() t.local_tracking = False t.track_local("LOCAL_TRACKED") t.ignore_global("GLOBAL_IGNORED") assert (t.is_tracked("DEFAULT", "LOCAL_TRACKED", "GLOBAL_IGNORED") == [False, True, False]) t.global_tracking = False t.ignore_local("LOCAL_IGNORED") t.track_global("GLOBAL_TRACKED") assert (t.is_tracked( "DEFAULT", "LOCAL_TRACKED", "LOCAL_IGNORED", "GLOBAL_TRACKED", "GLOBAL_IGNORED") == [False, True, False, True, False])
def test_empty_config(): L = nullcontext(dict()) G = nullcontext(dict()) t = VariableTracking(L, G) assert (t.default_tracking is True) assert (t.local_tracking is None) assert (t.global_tracking is True) with pytest.raises(KeyError): assert (t.is_tracked("FOO")) t.global_tracking = False assert (t.default_tracking is False) with pytest.raises(KeyError): assert (not t.is_tracked("FOO")) with pytest.raises(KeyError): t.track_local("FOO")