Skip to content

Commit

Permalink
Add target option to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed May 21, 2024
1 parent 6d71fc0 commit ff0c49f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 22 additions & 10 deletions .docker/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,29 @@

import pytest

TARGETS = ('aiida-core-base', 'aiida-core-base-with-services', 'aiida-core-dev')

@pytest.fixture(
scope='session',
params=[
'aiida-core-base',
'aiida-core-with-services',
'aiida-core-dev',
],
)
def variant(request):
return request.param

def target_checker(value):
msg = f"Invalid image target '{value}', must be one of: {TARGETS}"
if value not in TARGETS:
raise pytest.UsageError(msg)
return value


def pytest_addoption(parser):
parser.addoption(
'--target',
action='store',
required=True,
help='target (image name) of the docker-compose file to use.',
type=target_checker,
)


@pytest.fixture(scope='session')
def variant(pytestconfig):
return pytestconfig.getoption('target')


@pytest.fixture(scope='session')
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ jobs:
run: pip install -r requirements.txt --no-deps

- name: Run tests
run: pytest -s
run: pytest -s --target ${{ inputs.target }}
env: ${{ fromJSON(inputs.images) }}

0 comments on commit ff0c49f

Please sign in to comment.