Skip to content

Commit

Permalink
Amend test
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed Sep 9, 2023
1 parent 004d131 commit 197a6c6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,32 @@
@pytest.mark.parametrize(
'variable,value,raw_value,parse_comments',
[
# parse_comments=True
('BOOL_TRUE_STRING_LIKE_BOOL_WITH_COMMENT', 'True', "'True' # comment\n", True),
('BOOL_TRUE_BOOL_WITH_COMMENT', 'True ', "True # comment\n", True),
('STR_QUOTED_IGNORE_COMMENT', 'foo', " 'foo' # comment\n", True),
('STR_QUOTED_INCLUDE_HASH', 'foo # with hash', "'foo # with hash' # not comment\n", True),
('SECRET_KEY_1', '"abc', '"abc#def"\n', True),
('SECRET_KEY_2', 'abc', 'abc#def\n', True),
('SECRET_KEY_3', 'abc#def', "'abc#def'\n", True),
# parse_comments=False
('BOOL_TRUE_STRING_LIKE_BOOL_WITH_COMMENT', "'True' # comment", "'True' # comment\n", False),
('BOOL_TRUE_BOOL_WITH_COMMENT', 'True # comment', "True # comment\n", False),
('STR_QUOTED_IGNORE_COMMENT', " 'foo' # comment", " 'foo' # comment\n", False),
('STR_QUOTED_INCLUDE_HASH', "'foo # with hash' # not comment", "'foo # with hash' # not comment\n", False),
('SECRET_KEY_1', 'abc#def', '"abc#def"\n', False),
('SECRET_KEY_2', 'abc#def', 'abc#def\n', False),
('SECRET_KEY_3', 'abc#def', "'abc#def'\n", False),
# parse_comments is not defined (default behavior)
('BOOL_TRUE_STRING_LIKE_BOOL_WITH_COMMENT', "'True' # comment", "'True' # comment\n", None),
('BOOL_TRUE_BOOL_WITH_COMMENT', 'True # comment', "True # comment\n", None),
('STR_QUOTED_IGNORE_COMMENT', " 'foo' # comment", " 'foo' # comment\n", None),
('STR_QUOTED_INCLUDE_HASH', "'foo # with hash' # not comment", "'foo # with hash' # not comment\n", None),
('SECRET_KEY_1', 'abc#def', '"abc#def"\n', None),
('SECRET_KEY_2', 'abc#def', 'abc#def\n', None),
('SECRET_KEY_3', 'abc#def', "'abc#def'\n", None),
],
)
def test_parse_comments(variable, value, raw_value, parse_comments):
Expand All @@ -46,7 +65,10 @@ def test_parse_comments(variable, value, raw_value, parse_comments):

env = Env()
Env.ENVIRON = {}
env.read_env(env_path, parse_comments=parse_comments)
if parse_comments is None:
env.read_env(env_path)
else:
env.read_env(env_path, parse_comments=parse_comments)

assert env(variable) == value

Expand Down

0 comments on commit 197a6c6

Please sign in to comment.