Skip to content

Commit 5b8e700

Browse files
committed
add default vaule setting that will not override existing env variables
1 parent 68bd434 commit 5b8e700

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pytest_env/plugin.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,15 @@ def pytest_load_initial_conftests(args, early_config, parser):
1313
part = e.partition("=")
1414
key = part[0].strip()
1515
value = part[2].strip()
16-
os.environ[key] = value
16+
17+
# use D: as a way to designate a default value
18+
# that will only override env variables if they
19+
# do not exist already
20+
dkey = key.split("D:")
21+
default_val = False
22+
if len(dkey) == 2:
23+
key = dkey[1]
24+
default_val = True
25+
26+
if not default_val or key not in os.environ:
27+
os.environ[key] = value

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
name='pytest-env',
77
description=description,
88
long_description=description,
9-
version='0.5.1',
9+
version='0.6.0',
1010
1111
author_email='[email protected]',
1212
url='https://github.com/MobileDynasty/pytest-env',
@@ -24,4 +24,4 @@
2424
'Programming Language :: Python :: 3',
2525
'Programming Language :: Python :: 3.3',
2626
]
27-
)
27+
)

0 commit comments

Comments
 (0)