Skip to content

Commit

Permalink
Support new fixtures with sqlite backend
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Dec 2, 2024
1 parent 7caebdb commit 6b8b368
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
- name: Run test suite
env:
# show timings of tests
PYTEST_ADDOPTS: "--durations=0"
PYTEST_ADDOPTS: "--durations=10"
run: |
aiida-mock-code || true
cd tests; pytest
pytest -s
pre-commit:
runs-on: ubuntu-latest
Expand Down
20 changes: 15 additions & 5 deletions aiida_test_cache/mock_code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@

# Note: This is necessary for the sphinx doc - otherwise it does not find aiida_test_cache.mock_code.mock_code_factory
__all__ = (
"pytest_addoption",
"testing_config_action",
"mock_code_factory",
"mock_regenerate_test_data",
"pytest_addoption",
"testing_config",
"mock_code_factory",
"testing_config_action",
)

# ensure aiida's pytest plugin is loaded, which we rely on
pytest_plugins = ['aiida.manage.tests.pytest_fixtures']
# Load aiida's pytest fixtures
# For aiida-core>=2.6 we load new fixtures which use sqlite backend.
# WARNING: It's not clear what happens if the user later loads
# the old fixtures as well.
from aiida import __version__ as aiida_version
from pkg_resources import parse_version

if parse_version(aiida_version) >= parse_version('2.6.0'):
aiida_core_fixtures = 'aiida.tools.pytest_fixtures'
else:
aiida_core_fixtures = 'aiida.manage.tests.pytest_fixtures'
pytest_plugins = [aiida_core_fixtures]
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@ aiida_mock_code = "aiida_test_cache.mock_code"
aiida_archive_cache = "aiida_test_cache.archive_cache"

[tool.pytest.ini_options]
filterwarnings = []
addopts = '--durations-min=3 --strict-config --strict-markers -ra'
filterwarnings = [
'ignore:Creating AiiDA configuration:UserWarning:aiida',
# The following deprecation warnings come from Python 3.12 stdlib modules
"ignore:datetime.datetime.:DeprecationWarning:",
]

[tool.yapf]
based_on_style = "pep8"
Expand Down

0 comments on commit 6b8b368

Please sign in to comment.