def test_disabled_ctx(self): """ The `disabled` context manager disables running validators, but only within its context. """ assert _config._run_validators is True with validator_module.disabled(): assert _config._run_validators is False assert _config._run_validators is True
def test_disabled_ctx_with_errors(self): """ Running validators is re-enabled even if an error is raised. """ assert _config._run_validators is True with pytest.raises(ValueError): with validator_module.disabled(): assert _config._run_validators is False raise ValueError("haha!") assert _config._run_validators is True