diff options
| author | Tim Graham <timograham@gmail.com> | 2025-12-23 19:34:32 -0500 |
|---|---|---|
| committer | Jacob Walls <jacobtylerwalls@gmail.com> | 2026-02-09 17:46:33 -0500 |
| commit | 226ca7b5ce283e1f891dbbbefb0afaebdaa09f28 (patch) | |
| tree | a9b1068ee193a1d6de95c8216986dd533ce0930e /tests | |
| parent | 7cf1c22d4dfdd46f2082cfc55b714b68c4fd2de3 (diff) | |
Added DatabaseFeatures.supports_inspectdb.
Needed by MongoDB.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/inspectapp/tests.py | 1 | ||||
| -rw-r--r-- | tests/inspectdb/tests.py | 22 |
2 files changed, 21 insertions, 2 deletions
diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py index 43227d232d..fd6fec32d9 100644 --- a/tests/gis_tests/inspectapp/tests.py +++ b/tests/gis_tests/inspectapp/tests.py @@ -14,6 +14,7 @@ from ..test_data import TEST_DATA from .models import AllOGRFields +@skipUnlessDBFeature("supports_inspectdb") class InspectDbTests(TestCase): def test_geom_columns(self): """ diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py index 8175c52e4e..b677af23df 100644 --- a/tests/inspectdb/tests.py +++ b/tests/inspectdb/tests.py @@ -2,11 +2,16 @@ import re from io import StringIO from unittest import mock, skipUnless -from django.core.management import call_command +from django.core.management import CommandError, call_command from django.core.management.commands import inspectdb from django.db import connection from django.db.backends.base.introspection import TableInfo -from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature +from django.test import ( + TestCase, + TransactionTestCase, + skipIfDBFeature, + skipUnlessDBFeature, +) from .models import PeopleMoreData, test_collation @@ -40,6 +45,7 @@ def cursor_execute(*queries): return results +@skipUnlessDBFeature("supports_inspectdb") class InspectDBTestCase(TestCase): unique_re = re.compile(r".*unique_together = \((.+),\).*") @@ -519,6 +525,7 @@ class InspectDBTestCase(TestCase): ) +@skipUnlessDBFeature("supports_inspectdb") class InspectDBTransactionalTests(TransactionTestCase): available_apps = ["inspectdb"] @@ -671,3 +678,14 @@ class InspectDBTransactionalTests(TransactionTestCase): out = StringIO() call_command("inspectdb", "inspectdb_compositepkmodel", stdout=out) self.assertNotIn("unique_together", out.getvalue()) + + +@skipIfDBFeature("supports_inspectdb") +class InspectDBNotSupportedTests(TestCase): + def test_not_supported(self): + msg = ( + "Database inspection isn't supported for the currently selected " + "database backend." + ) + with self.assertRaisesMessage(CommandError, msg): + call_command("inspectdb") |
