Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Parse single quotes
  • Loading branch information
Flimm committed Mar 30, 2017
commit 9b5582ea85c99f704bce9012c2741d28b46981ed
2 changes: 1 addition & 1 deletion dotenv/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def parse_dotenv(dotenv_path):
k, v = k.strip(), v.strip()

if len(v) > 0:
quoted = v[0] == v[len(v) - 1] == '"'
quoted = v[0] == v[len(v) - 1] in ['"', "'"]

if quoted:
v = decode_escaped(v[1:-1])
Expand Down
12 changes: 12 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ def test_key_value_without_quotes():
sh.rm(dotenv_path)


def test_value_with_quotes():
with open(dotenv_path, 'w') as f:
f.write('TEST="two words"\n')
assert dotenv.get_key(dotenv_path, 'TEST') == 'two words'
sh.rm(dotenv_path)

with open(dotenv_path, 'w') as f:
f.write("TEST='two words'\n")
assert dotenv.get_key(dotenv_path, 'TEST') == 'two words'
sh.rm(dotenv_path)


def test_unset():
sh.touch(dotenv_path)
success, key_to_set, value_to_set = dotenv.set_key(dotenv_path, 'HELLO', 'WORLD')
Expand Down