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 Nov 28, 2024
1 parent 801cbb9 commit d94c927
Show file tree
Hide file tree
Showing 3 changed files with 22 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
19 changes: 14 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,21 @@

# 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
try:
# These new fixtures which use sqlite backend, introduced in aiida v2.6
# NOTE: It's not clear what happens if the user than activates
# the old fixtures as well.
import aiida.tools.pytest_fixtures # type: ignore[import-not-found] # noqa: F401
except ImportError:
aiida_core_fixtures = 'aiida.manage.tests.pytest_fixtures'
else:
aiida_core_fixtures = 'aiida.tools.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 d94c927

Please sign in to comment.