Skip to content

Commit 9fe8fd2

Browse files
authored
Fixtures: Make pgtest truly an optional dependency (#6502)
The pytest fixtures were improved to allow running with a `core.sqlite_dos` storage for the test profile, making PostgreSQL completely optional. However, the current fixture still imports the `pgtest` package at module level making it a requirement, despite it only being relevant when running the tests with a `core.psql_dos` storage plugin. Here the import is moved inside the `PostgresCluster._create` method which is only called when the test suite actually uses a PSQL based storage plugin.
1 parent 2ccfeee commit 9fe8fd2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/aiida/tools/pytest_fixtures/storage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from uuid import uuid4
88

99
import pytest
10-
from pgtest.pgtest import PGTest
1110

1211
if t.TYPE_CHECKING:
1312
from pgtest.pgtest import PGTest
@@ -19,6 +18,8 @@ def __init__(self):
1918
self.cluster = None
2019

2120
def _create(self):
21+
from pgtest.pgtest import PGTest
22+
2223
try:
2324
self.cluster = PGTest()
2425
except OSError as e:
@@ -59,7 +60,6 @@ def create_database(
5960
return postgres_config
6061

6162

62-
# TODO: Update docstring accordingly
6363
@pytest.fixture(scope='session')
6464
def postgres_cluster():
6565
"""Create a temporary and isolated PostgreSQL cluster using ``pgtest`` and cleanup after the yield.

0 commit comments

Comments
 (0)