Skip to content

Commit 844301b

Browse files
committed
🧪 Gate secure-storage tests by marker
Register `requires_secure_storage` and mark tests which need a system password manager backend. Skip those tests unless the marker is explicitly selected so local runs do not fail on machines without usable secure storage. CI selects the marker so keyring misconfiguration still causes a normal test failure instead of silently losing coverage.
1 parent 94835b5 commit 844301b

6 files changed

Lines changed: 21 additions & 9 deletions

File tree

‎.github/workflows/ci-code.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
AIIDA_TEST_PROFILE: test_aiida
7474
AIIDA_WARN_v3: 1
7575
run: |
76-
pytest -n auto --db-backend ${{ matrix.database-backend }} --broker-backend ${{ matrix.broker-backend }} -m 'not nightly' tests/ ${{ matrix.python-version == '3.14' && '--cov aiida' || '' }}
76+
pytest -n auto --db-backend ${{ matrix.database-backend }} --broker-backend ${{ matrix.broker-backend }} -m 'not nightly or requires_secure_storage' tests/ ${{ matrix.python-version == '3.14' && '--cov aiida' || '' }}
7777
7878
- name: Upload coverage report
7979
if: matrix.python-version == 3.14 && github.repository == 'aiidateam/aiida-core'
@@ -125,7 +125,7 @@ jobs:
125125
- name: Run test suite
126126
env:
127127
AIIDA_WARN_v3: 0
128-
run: pytest --disable-warnings -n auto --db-backend ${{ matrix.database-backend }} --broker-backend zmq -m 'not nightly' tests/
128+
run: pytest --disable-warnings -n auto --db-backend ${{ matrix.database-backend }} --broker-backend zmq -m 'not nightly or requires_secure_storage' tests/
129129

130130

131131
tests-presto:

‎.github/workflows/test-install.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ jobs:
215215
AIIDA_TEST_PROFILE: test_aiida
216216
AIIDA_WARN_v3: 1
217217
run: |
218-
pytest -n auto --db-backend psql -m 'not nightly' tests/
218+
pytest -n auto --db-backend psql -m 'not nightly or requires_secure_storage' tests/
219219
220220
- name: Slack notification
221221
# Run this step if any of the previous steps fail.

‎pyproject.toml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ markers = [
444444
'requires_rmq: requires RabbitMQ specifically (not compatible with ZeroMQ broker)',
445445
'requires_broker: requires a message broker (RabbitMQ or ZeroMQ)',
446446
'requires_psql: requires a connection to PostgreSQL DB',
447-
'presto: automatic marker for tests needing no external services (not requires_rmq, not requires_psql)',
447+
'requires_secure_storage: requires a system secure storage backend',
448+
'presto: automatic marker for tests needing no external services (not requires_rmq, not requires_psql, not requires_secure_storage)',
448449
'sphinx: set parameters for the sphinx `app` fixture'
449450
]
450451
minversion = '7.0'

‎tests/conftest.py‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ def pytest_collection_modifyitems(items, config):
6969
"""Automatically generate markers for certain tests.
7070
7171
Most notably, we add the 'presto' marker for all tests that
72-
are not marked with requires_rmq, requires_psql, or nightly.
72+
are not marked with requires_rmq, requires_psql, requires_secure_storage, or nightly.
7373
Tests marked requires_broker are included in presto since ZeroMQ
7474
broker is available without external services.
7575
"""
7676
filepath_psqldos = Path(__file__).parent / 'storage' / 'psql_dos'
7777
filepath_django = Path(__file__).parent / 'storage' / 'psql_dos' / 'migrations' / 'django_branch'
7878
filepath_sqla = Path(__file__).parent / 'storage' / 'psql_dos' / 'migrations' / 'sqlalchemy_branch'
79+
user_markexpr = config.option.markexpr
7980

8081
# If the user requested the SQLite backend, automatically skip incompatible tests
8182
if config.option.db_backend is TestDbBackend.SQLITE:
@@ -118,11 +119,20 @@ def pytest_collection_modifyitems(items, config):
118119
if filepath_item.is_relative_to(filepath_psqldos):
119120
item.add_marker('requires_psql')
120121

122+
markers = [marker.name for marker in item.iter_markers()]
123+
124+
if 'requires_secure_storage' in markers and 'requires_secure_storage' not in user_markexpr:
125+
item.add_marker(pytest.mark.skip(reason='requires secure storage; select with -m requires_secure_storage'))
126+
121127
# Add 'presto' marker to tests that don't need external services.
122128
# Tests with requires_broker ARE included (ZeroMQ broker needs no external service).
123-
# Tests with requires_rmq, requires_psql, or nightly are excluded.
124-
markers = [marker.name for marker in item.iter_markers()]
125-
if 'requires_rmq' not in markers and 'requires_psql' not in markers and 'nightly' not in markers:
129+
# Tests with requires_rmq, requires_psql, requires_secure_storage, or nightly are excluded.
130+
if (
131+
'requires_rmq' not in markers
132+
and 'requires_psql' not in markers
133+
and 'requires_secure_storage' not in markers
134+
and 'nightly' not in markers
135+
):
126136
item.add_marker('presto')
127137

128138

‎tests/orm/test_authinfos.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from aiida.orm.implementation.authinfos import BackendAuthInfo
1919

2020

21+
@pytest.mark.requires_secure_storage
2122
class TestAuthinfo:
2223
"""Unit tests for the AuthInfo ORM class."""
2324

‎tests/transports/test_all_plugins.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def tmp_path_local(tmp_path_factory):
6767
('core.ssh_async', 'asyncssh'),
6868
('core.ssh_async', 'openssh'),
6969
('core.ssh_async', 'password-passed'),
70-
('core.ssh_async', 'password-from-keychain'),
70+
pytest.param(('core.ssh_async', 'password-from-keychain'), marks=pytest.mark.requires_secure_storage),
7171
],
7272
)
7373
def custom_transport(request, aiida_localhost) -> Transport:

0 commit comments

Comments
 (0)