Skip to content

Commit

Permalink
DevOps: Do not assume pgtest cluster started in postgres_cluster
Browse files Browse the repository at this point in the history
…fixture (#6050)

When a developer tries to run tests without Posgres installed, in addition
to the original exception coming from the `pgtest` library, one would
also get a rather unhelpful exception coming from AiiDA fixture which
tries to close the non-existent DB connection in the `finally` clause.
  • Loading branch information
danielhollas committed Jun 6, 2023
1 parent ad4fbcc commit 1de2ca5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion aiida/manage/tests/pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def postgres_cluster(
'database_password': database_password or 'guest',
}

cluster = None
try:
cluster = PGTest()

Expand All @@ -107,7 +108,8 @@ def postgres_cluster(

yield postgres_config
finally:
cluster.close()
if cluster is not None:
cluster.close()


@pytest.fixture(scope='session')
Expand Down

0 comments on commit 1de2ca5

Please sign in to comment.