Skip to content

Commit

Permalink
move test default environment variables
Browse files Browse the repository at this point in the history
Use pytest to provide default environment variables for testing instead
of defining them in multiple places.

This would enable users to run pytest outisde tox without having to
define extra variables.

Signed-off-by: Sorin Sbarnea <[email protected]>
  • Loading branch information
ssbarnea committed Oct 24, 2019
1 parent 60fe1ed commit 081cd32
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 4 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ def environ():
# [ERROR]: failed to download the file: HTTP Error 401: Unauthorized
# https://github.com/ansible/ansible/issues/61666
os.environ['NETRC'] = ''

# adds extra environment variables that may be needed during testing
if not os.environ.get('TEST_BASE_IMAGE', ""):
os.environ['TEST_BASE_IMAGE'] = 'docker.io/pycontribs/centos:7'
2 changes: 1 addition & 1 deletion molecule/test/functional/docker/test_scenarios.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_command_test_builds_local_molecule_image(
scenario_to_test, with_scenario, scenario_name, driver_name
):
try:
image = os.environ.get('TEST_BASE_IMAGE', "docker.io/pycontribs/centos:7")
image = os.environ['TEST_BASE_IMAGE']
cmd = sh.docker.bake('rmi', 'molecule_local/{}'.format(image), '--force')
pytest.helpers.run_command(cmd)
except sh.ErrorReturnCode:
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ passenv = *
setenv =
ANSIBLE_CALLABLE_WHITELIST={env:ANSIBLE_CALLABLE_WHITELIST:timer,profile_roles}
PYTHONDONTWRITEBYTECODE=1
TEST_BASE_IMAGE=docker.io/pycontribs/centos:7
# -n auto used only on unit as is not supported by functional yet
unit: PYTEST_ADDOPTS=molecule/test/unit/ --cov={toxinidir}/molecule/ --no-cov-on-fail {env:PYTEST_ADDOPTS:-n auto}
functional: PYTEST_ADDOPTS=molecule/test/functional/ {env:PYTEST_ADDOPTS:}
Expand Down

0 comments on commit 081cd32

Please sign in to comment.