Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions decouple.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ def __init__(self, source, encoding=DEFAULT_ENCODING):
line = line.strip()
if not line or line.startswith('#') or '=' not in line:
continue
if line.startswith('export ') or line.startswith('export\t'):
line = line[7:].lstrip()
if not line or '=' not in line:
continue
k, v = line.split('=', 1)
k = k.strip()
v = v.strip()
Expand Down
7 changes: 7 additions & 0 deletions tests/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
KeyHasTwoDoubleQuote='"Y"'
KeyHasMixedQuotesAsData1="Y'
KeyHasMixedQuotesAsData2='Y"
export ExportedKey=fromexport
export ExportedTab=tabs
'''

@pytest.fixture(scope='module')
Expand Down Expand Up @@ -140,3 +142,8 @@ def test_env_with_quote(config):
def test_env_repo_keyerror(config):
with pytest.raises(KeyError):
config.repository['UndefinedKey']


def test_env_export_prefix(config):
assert 'fromexport' == config('ExportedKey')
assert 'tabs' == config('ExportedTab')