Skip to content

Commit

Permalink
Keep pytest verbosity and rename DbBackend
Browse files Browse the repository at this point in the history
  • Loading branch information
GeigerJ2 committed Nov 22, 2024
1 parent 6104928 commit 3ec5b76
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ jobs:
AIIDA_WARN_v3: 1
# Python 3.12 has a performance regression when running with code coverage
# so run code coverage only for python 3.9.
run: pytest --db-backend psql -m 'not nightly' tests/ ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}
run: pytest -v --db-backend psql -m 'not nightly' tests/ ${{ matrix.python-version == '3.9' && '--cov aiida' || '' }}

- name: Upload coverage report
if: matrix.python-version == 3.9 && github.repository == 'aiidateam/aiida-core'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
id: tests
env:
AIIDA_WARN_v3: 0
run: pytest --db-backend sqlite -m 'requires_rmq' tests/
run: pytest -sv -db-backend sqlite -m 'requires_rmq' tests/

- name: Slack notification
# Always run this step (otherwise it would be skipped if any of the previous steps fail) but only if the
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
uses: ./.github/actions/install-aiida-core

- name: Run sub-set of test suite
run: pytest -s -m requires_rmq --db-backend=sqlite tests/
run: pytest -sv -m requires_rmq --db-backend=sqlite tests/

publish:

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
env:
AIIDA_TEST_PROFILE: test_aiida
AIIDA_WARN_v3: 1
run: pytest --db-backend psql tests -m 'not nightly' tests/
run: pytest -v --db-backend psql tests -m 'not nightly' tests/

- name: Freeze test environment
run: pip freeze | sed '1d' | tee requirements-py-${{ matrix.python-version }}.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_nightly.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ verdi -p test_aiida run ${SYSTEM_TESTS}/test_containerized_code.py
bash ${SYSTEM_TESTS}/test_polish_workchains.sh
verdi daemon stop

AIIDA_TEST_PROFILE=test_aiida pytest --db-backend psql -m nightly tests/
AIIDA_TEST_PROFILE=test_aiida pytest -v --db-backend psql -m nightly tests/
16 changes: 8 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
pytest_plugins = ['aiida.tools.pytest_fixtures', 'sphinx.testing.fixtures']


class DbBackend(Enum):
class TestDbBackend(Enum):
"""Options for the '--db-backend' CLI argument"""

SQLITE = 'sqlite'
Expand All @@ -56,7 +56,7 @@ def pytest_collection_modifyitems(items, config):
filepath_sqla = Path(__file__).parent / 'storage' / 'psql_dos' / 'migrations' / 'sqlalchemy_branch'

# If the user requested the SQLite backend, automatically skip incompatible tests
if config.option.db_backend is DbBackend.SQLITE:
if config.option.db_backend is TestDbBackend.SQLITE:
if config.option.markexpr != '':
# Don't overwrite markers that the user already provided via '-m ' cmdline argument
config.option.markexpr += ' and (not requires_psql)'
Expand Down Expand Up @@ -91,19 +91,19 @@ def db_backend_type(string):
:returns: DbBackend enum corresponding to user input string
"""
try:
return DbBackend(string)
return TestDbBackend(string)
except ValueError:
msg = f"Invalid --db-backend option '{string}'\nMust be one of: {tuple(db.value for db in DbBackend)}"
msg = f"Invalid --db-backend option '{string}'\nMust be one of: {tuple(db.value for db in TestDbBackend)}"
raise pytest.UsageError(msg)


def pytest_addoption(parser):
parser.addoption(
'--db-backend',
action='store',
default=DbBackend.SQLITE,
default=TestDbBackend.SQLITE,
required=False,
help=f'Database backend to be used for tests {tuple(db.value for db in DbBackend)}',
help=f'Database backend to be used for tests {tuple(db.value for db in TestDbBackend)}',
type=db_backend_type,
)

Expand All @@ -124,10 +124,10 @@ def aiida_profile(pytestconfig, aiida_config, aiida_profile_factory, config_psql
if 'not requires_rmq' in marker_opts or 'presto' in marker_opts:
broker = None

if db_backend is DbBackend.SQLITE:
if db_backend is TestDbBackend.SQLITE:
storage = 'core.sqlite_dos'
config = config_sqlite_dos()
elif db_backend is DbBackend.PSQL:
elif db_backend is TestDbBackend.PSQL:
storage = 'core.psql_dos'
config = config_psql_dos()
else:
Expand Down

0 comments on commit 3ec5b76

Please sign in to comment.