mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-14 12:53:47 +03:00
Add tests for an empty environment variable
This commit is contained in:
parent
d9984a55ef
commit
3cc54462bd
|
@ -106,9 +106,11 @@ def environment_variables():
|
|||
os.environ["CONFIG_TEST_ENV"] = "test-value"
|
||||
os.environ["CONFIG_TEST_PATH"] = "test-path"
|
||||
os.environ["DEFINED"] = "defined"
|
||||
os.environ["EMPTY"] = ""
|
||||
os.environ["CONFIG_INT"] = "42"
|
||||
yield
|
||||
os.environ.pop("CONFIG_TEST_ENV", None)
|
||||
os.environ.pop("CONFIG_TEST_PATH", None)
|
||||
os.environ.pop("DEFINED", None)
|
||||
os.environ.pop("EMPTY", None)
|
||||
os.environ.pop("CONFIG_INT", None)
|
||||
|
|
|
@ -49,6 +49,12 @@ def test_as__undefined_required(config):
|
|||
assert config() == {}
|
||||
|
||||
|
||||
def test_as__defined_empty(config):
|
||||
with raises(ValueError):
|
||||
config.from_env("EMPTY", as_=int)
|
||||
assert config() == {}
|
||||
|
||||
|
||||
def test_option_as_(config):
|
||||
config.option.from_env("CONFIG_INT", as_=int)
|
||||
assert config.option() == 42
|
||||
|
@ -67,6 +73,12 @@ def test_option_as__undefined_required(config):
|
|||
assert config.option() is None
|
||||
|
||||
|
||||
def test_option_as__defined_empty(config):
|
||||
with raises(ValueError):
|
||||
config.option.from_env("EMPTY", as_=int)
|
||||
assert config.option() is None
|
||||
|
||||
|
||||
@mark.parametrize("config_type", ["strict"])
|
||||
def test_undefined_in_strict_mode(config):
|
||||
with raises(ValueError):
|
||||
|
|
Loading…
Reference in New Issue
Block a user