def test_tempconfig(using_opengl_renderer): """Test the tempconfig context manager.""" original = config.copy() with tempconfig({"frame_width": 100, "frame_height": 42}): # check that config was modified correctly assert config["frame_width"] == 100 assert config["frame_height"] == 42 # check that no keys are missing and no new keys were added assert set(original.keys()) == set(config.keys()) # check that the keys are still untouched assert set(original.keys()) == set(config.keys()) # check that config is correctly restored for k, v in original.items(): if isinstance(v, np.ndarray): assert np.allclose(config[k], v) else: assert config[k] == v
def test_tempconfig(): """Test the tempconfig context manager.""" original = config.copy() with tempconfig({"frame_width": 100, "frame_height": 42, "foo": -1}): # check that config was modified correctly assert config["frame_width"] == 100 assert config["frame_height"] == 42 # 'foo' is not a key in the original dict so it shouldn't be added assert "foo" not in config # check that no keys are missing and no new keys were added assert set(original.keys()) == set(config.keys()) # check that the keys are still untouched assert set(original.keys()) == set(config.keys()) # check that config is correctly restored for k, v in original.items(): if isinstance(v, np.ndarray): assert np.allclose(config[k], v) else: assert config[k] == v