Skip to content

Commit 4b8c723

Browse files
author
Saurabh Kumar
committed
Add tests for parse_line
1 parent c13fab4 commit 4b8c723

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/test_core.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,27 @@
88
import sh
99

1010
from dotenv import load_dotenv, find_dotenv, set_key, dotenv_values
11+
from dotenv.main import parse_line
1112
from dotenv.compat import StringIO
1213
from IPython.terminal.embed import InteractiveShellEmbed
1314

1415

16+
@pytest.mark.parametrize("test_input,expected", [
17+
("a=b", ("a", "b")),
18+
(" a = b ", ("a", "b")),
19+
("export a=b", ("a", "b")),
20+
(" export 'a'=b", ("'a'", "b")),
21+
(" export 'a'=b", ("'a'", "b")),
22+
("# a=b", (None, None)),
23+
("# a=b", (None, None)),
24+
("a=b space ", ('a', 'b space')),
25+
("a='b space '", ('a', 'b space ')),
26+
('a="b space "', ('a', 'b space ')),
27+
])
28+
def test_parse_line(test_input, expected):
29+
assert parse_line(test_input) == expected
30+
31+
1532
def test_warns_if_file_does_not_exist():
1633
with warnings.catch_warnings(record=True) as w:
1734
load_dotenv('.does_not_exist', verbose=True)

0 commit comments

Comments
 (0)