summaryrefslogtreecommitdiff
path: root/test/orm/test_relationships.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-01-21 18:46:37 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-01-22 19:17:10 -0500
commitde0b4db838e26fe61953c7765f35d5b7be581646 (patch)
tree89f9816c86dbf9eaec0406b6a9b8585e9b645a6c /test/orm/test_relationships.py
parentd46a4c0326bd2e697794514b920e6727d5153324 (diff)
downloadsqlalchemy-de0b4db838e26fe61953c7765f35d5b7be581646.tar.gz
dont use exception catches for warnings; modernize xdist detection
Improvements to the test suite's integration with pytest such that the "warnings" plugin, if manually enabled, will not interfere with the test suite, such that third parties can enable the warnings plugin or make use of the ``-W`` parameter and SQLAlchemy's test suite will continue to pass. Additionally, modernized the detection of the "pytest-xdist" plugin so that plugins can be globally disabled using PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 without breaking the test suite if xdist were still installed. Warning filters that promote deprecation warnings to errors are now localized to SQLAlchemy-specific warnings, or within SQLAlchemy-specific sources for general Python deprecation warnings, so that non-SQLAlchemy deprecation warnings emitted from pytest plugins should also not impact the test suite. Fixes: #7599 Change-Id: Ibcf09af25228d39ee5a943fda82d8a9302433726
Diffstat (limited to 'test/orm/test_relationships.py')
-rw-r--r--test/orm/test_relationships.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/test/orm/test_relationships.py b/test/orm/test_relationships.py
index f91e7e8d5..fd192ab51 100644
--- a/test/orm/test_relationships.py
+++ b/test/orm/test_relationships.py
@@ -33,13 +33,14 @@ from sqlalchemy.orm.interfaces import MANYTOONE
from sqlalchemy.orm.interfaces import ONETOMANY
from sqlalchemy.testing import assert_raises
from sqlalchemy.testing import assert_raises_message
+from sqlalchemy.testing import assert_warns_message
from sqlalchemy.testing import AssertsCompiledSQL
from sqlalchemy.testing import eq_
+from sqlalchemy.testing import expect_raises_message
+from sqlalchemy.testing import expect_warnings
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import in_
from sqlalchemy.testing import is_
-from sqlalchemy.testing.assertions import expect_raises_message
-from sqlalchemy.testing.assertions import expect_warnings
from sqlalchemy.testing.assertsql import assert_engine
from sqlalchemy.testing.assertsql import CompiledSQL
from sqlalchemy.testing.fixtures import fixture_session
@@ -873,7 +874,7 @@ class OverlappingFksSiblingTest(fixtures.MappedTest):
@testing.provide_metadata
def test_simple_warn(self):
- assert_raises_message(
+ assert_warns_message(
exc.SAWarning,
r"relationship '(?:Child.parent|Parent.children)' will copy "
r"column parent.id to column child.parent_id, which conflicts "
@@ -964,7 +965,7 @@ class OverlappingFksSiblingTest(fixtures.MappedTest):
@testing.provide_metadata
def test_double_rel_same_mapper_warns(self):
- assert_raises_message(
+ assert_warns_message(
exc.SAWarning,
r"relationship 'Parent.child[12]' will copy column parent.id to "
r"column child.parent_id, which conflicts with relationship\(s\): "
@@ -984,7 +985,7 @@ class OverlappingFksSiblingTest(fixtures.MappedTest):
@testing.provide_metadata
def test_warn_one(self):
- assert_raises_message(
+ assert_warns_message(
exc.SAWarning,
r"relationship '(?:BSub1.a|BSub2.a_member|B.a)' will copy column "
r"(?:a.id|a_member.a_id) to column b.a_id",
@@ -995,7 +996,7 @@ class OverlappingFksSiblingTest(fixtures.MappedTest):
@testing.provide_metadata
def test_warn_two(self):
- assert_raises_message(
+ assert_warns_message(
exc.SAWarning,
r"relationship '(?:BSub1.a|B.a_member)' will copy column "
r"(?:a.id|a_member.a_id) to column b.a_id",
@@ -1006,7 +1007,7 @@ class OverlappingFksSiblingTest(fixtures.MappedTest):
@testing.provide_metadata
def test_warn_three(self):
- assert_raises_message(
+ assert_warns_message(
exc.SAWarning,
r"relationship '(?:BSub1.a|B.a_member|B.a)' will copy column "
r"(?:a.id|a_member.a_id) to column b.a_id",
@@ -1018,7 +1019,7 @@ class OverlappingFksSiblingTest(fixtures.MappedTest):
@testing.provide_metadata
def test_warn_four(self):
- assert_raises_message(
+ assert_warns_message(
exc.SAWarning,
r"relationship '(?:B.a|BSub2.a_member|B.a)' will copy column "
r"(?:a.id|a_member.a_id) to column b.a_id",
@@ -1302,7 +1303,7 @@ class CompositeSelfRefFKTest(fixtures.MappedTest, AssertsCompiledSQL):
},
)
- assert_raises_message(
+ assert_warns_message(
exc.SAWarning,
r"relationship .* will copy column .* to column "
r"employee_t.company_id, which conflicts with relationship\(s\)",