diff --git a/tests/test_environ.py b/tests/test_environ.py index 9bf551c2e..e40a195e1 100644 --- a/tests/test_environ.py +++ b/tests/test_environ.py @@ -576,6 +576,21 @@ def test_env_get_defaults(): assert "TEST_REG_DNG" not in env +def test_env_class_repr(): + """Class with repr return string if env var.""" + + class Cls: + def __init__(self, var): + self.var = var + + def __repr__(self): + return self.var + + env = Env(CLS=Cls("hello")) + assert str(env.get("CLS")) == "hello" + assert str(env.__getitem__("CLS")) == "hello" + + @pytest.mark.parametrize( "val,validator", [ diff --git a/tests/test_integrations.py b/tests/test_integrations.py index 79231a681..5970d845d 100644 --- a/tests/test_integrations.py +++ b/tests/test_integrations.py @@ -498,6 +498,24 @@ else: 0, ), # + # test env with class + # + ( + """ +class Cls: + def __init__(self, var): + self.var = var + def __repr__(self): + return self.var + +$VAR = Cls("hello") +print($VAR) +echo $VAR +""", + "hello\nhello\n", + 0, + ), + # # test logical subprocess operators # (