Skip to content

Commit

Permalink
SQLA v2 API: Suppress known SAWarnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Sep 16, 2021
1 parent 6aa8281 commit 582a693
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/backends/aiida_sqlalchemy/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
###########################################################################
# pylint: disable=import-error,no-name-in-module
"""Test object relationships in the database."""
import warnings

from sqlalchemy import exc as sa_exc

from aiida.backends.testbase import AiidaTestCase
from aiida.backends.sqlalchemy.models.user import DbUser
from aiida.backends.sqlalchemy.models.node import DbNode
Expand Down Expand Up @@ -111,9 +115,6 @@ def test_user_node_2(self):
storing USER does NOT induce storage of the NODE
Assert the correct storage of user and node."""
import warnings
from sqlalchemy import exc as sa_exc

# Create user
dbu1 = DbUser('tests2@schema', 'spam', 'eggs', 'monty')

Expand Down Expand Up @@ -164,7 +165,10 @@ def test_user_node_3(self):

# Add only first node and commit
session.add(dbn_1)
session.commit()
with warnings.catch_warnings():
# suppress known SAWarning that we have not added dbn_2
warnings.simplefilter('ignore', category=sa_exc.SAWarning)
session.commit()

# Check for which object a pk has been assigned, which means that
# things have been at least flushed into the database
Expand Down Expand Up @@ -200,7 +204,10 @@ def test_user_node_4(self):

# Add only first node and commit
session.add(dbn_1)
session.commit()
with warnings.catch_warnings():
# suppress known SAWarning that we have not add the other nodes
warnings.simplefilter('ignore', category=sa_exc.SAWarning)
session.commit()

# Check for which object a pk has been assigned, which means that
# things have been at least flushed into the database
Expand Down

0 comments on commit 582a693

Please sign in to comment.