]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add more `requires` to tests for easier dialect tests management
authorKarol Gongola <karol.gongola@cledar.com>
Wed, 26 Feb 2025 10:06:16 +0000 (05:06 -0500)
committerFederico Caselli <cfederico87@gmail.com>
Wed, 26 Feb 2025 19:37:44 +0000 (20:37 +0100)
<!-- Provide a general summary of your proposed changes in the Title field above -->

### Description
<!-- Describe your changes in detail -->
I am just going through starrocks dialect tests. I have figured out that adding some requires for tests may be useful also for other dialects. So this is a proposal of adding them to sqlalchemy. Please let me know if it is aligned with your approach.

### Checklist
<!-- go over following points. check them with an `x` if they do apply, (they turn into clickable checkboxes once the PR is submitted, so no need to do everything at once)

-->

This pull request is:

- [x] A documentation / typographical / small typing error fix
- Good to go, no issue or tests are needed
- [ ] A short code fix
- please include the issue number, and create an issue if none exists, which
  must include a complete example of the issue.  one line code fixes without an
  issue and demonstration will not be accepted.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.   one line code fixes without tests will not be accepted.
- [ ] A new feature implementation
- please include the issue number, and create an issue if none exists, which must
  include a complete example of how the feature would look.
- Please include: `Fixes: #<issue number>` in the commit message
- please include tests.

**Have a nice day!**

Closes: #12362
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12362
Pull-request-sha: 932d341f5f16f0c5cadc39d3a67b0f10297177ce

Change-Id: If9fa9f7477040620d131dcbe087fb4b50fd08a08
(cherry picked from commit 24b86ad6e50d4a6723a45b2580f416ca981bab55)

lib/sqlalchemy/testing/requirements.py
lib/sqlalchemy/testing/suite/test_reflection.py
lib/sqlalchemy/testing/suite/test_select.py
lib/sqlalchemy/testing/suite/test_types.py

index bbf56a059a1ae445a0a194b6aabacf41577eb156..93541dca70efaaf4bea480dc067e7dfb2ff32065 100644 (file)
@@ -1826,3 +1826,9 @@ class SuiteRequirements(Requirements):
     def supports_bitwise_shift(self):
         """Target database supports bitwise left or right shift"""
         return exclusions.closed()
+
+    @property
+    def like_escapes(self):
+        """Target backend supports custom ESCAPE characters
+        with LIKE comparisons"""
+        return exclusions.open()
index 54d0d449a90bf9c4000c04d8cdd96c9f10f19023..2837e9fe0a33cff3e8aa5804a25b63a91a8da5fd 100644 (file)
@@ -220,6 +220,7 @@ class HasTableTest(OneConnectionTablesTest):
 
 class HasIndexTest(fixtures.TablesTest):
     __backend__ = True
+    __requires__ = ("index_reflection",)
 
     @classmethod
     def define_tables(cls, metadata):
@@ -298,6 +299,7 @@ class BizarroCharacterFKResolutionTest(fixtures.TestBase):
     """tests for #10275"""
 
     __backend__ = True
+    __requires__ = ("foreign_key_constraint_reflection",)
 
     @testing.combinations(
         ("id",), ("(3)",), ("col%p",), ("[brack]",), argnames="columnname"
@@ -474,11 +476,13 @@ class QuotedNameArgumentTest(fixtures.TablesTest):
         assert insp.get_pk_constraint(name)
 
     @quote_fixtures
+    @testing.requires.foreign_key_constraint_reflection
     def test_get_foreign_keys(self, name):
         insp = inspect(config.db)
         assert insp.get_foreign_keys(name)
 
     @quote_fixtures
+    @testing.requires.index_reflection
     def test_get_indexes(self, name):
         insp = inspect(config.db)
         assert insp.get_indexes(name)
index 7eb5cd0055d8c503e79a34e21a2a2125c0b0b3f4..b9e8b11efec48143fd81420e7519ac7e2c7737d2 100644 (file)
@@ -1541,6 +1541,7 @@ class LikeFunctionsTest(fixtures.TablesTest):
         col = self.tables.some_table.c.data
         self._test(col.startswith("ab%c"), {1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
 
+    @testing.requires.like_escapes
     def test_startswith_autoescape(self):
         col = self.tables.some_table.c.data
         self._test(col.startswith("ab%c", autoescape=True), {3})
@@ -1552,10 +1553,12 @@ class LikeFunctionsTest(fixtures.TablesTest):
             {1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
         )
 
+    @testing.requires.like_escapes
     def test_startswith_escape(self):
         col = self.tables.some_table.c.data
         self._test(col.startswith("ab##c", escape="#"), {7})
 
+    @testing.requires.like_escapes
     def test_startswith_autoescape_escape(self):
         col = self.tables.some_table.c.data
         self._test(col.startswith("ab%c", autoescape=True, escape="#"), {3})
@@ -1571,14 +1574,17 @@ class LikeFunctionsTest(fixtures.TablesTest):
             col.endswith(literal_column("'e%fg'")), {1, 2, 3, 4, 5, 6, 7, 8, 9}
         )
 
+    @testing.requires.like_escapes
     def test_endswith_autoescape(self):
         col = self.tables.some_table.c.data
         self._test(col.endswith("e%fg", autoescape=True), {6})
 
+    @testing.requires.like_escapes
     def test_endswith_escape(self):
         col = self.tables.some_table.c.data
         self._test(col.endswith("e##fg", escape="#"), {9})
 
+    @testing.requires.like_escapes
     def test_endswith_autoescape_escape(self):
         col = self.tables.some_table.c.data
         self._test(col.endswith("e%fg", autoescape=True, escape="#"), {6})
@@ -1588,14 +1594,17 @@ class LikeFunctionsTest(fixtures.TablesTest):
         col = self.tables.some_table.c.data
         self._test(col.contains("b%cde"), {1, 2, 3, 4, 5, 6, 7, 8, 9})
 
+    @testing.requires.like_escapes
     def test_contains_autoescape(self):
         col = self.tables.some_table.c.data
         self._test(col.contains("b%cde", autoescape=True), {3})
 
+    @testing.requires.like_escapes
     def test_contains_escape(self):
         col = self.tables.some_table.c.data
         self._test(col.contains("b##cde", escape="#"), {7})
 
+    @testing.requires.like_escapes
     def test_contains_autoescape_escape(self):
         col = self.tables.some_table.c.data
         self._test(col.contains("b%cd", autoescape=True, escape="#"), {3})
index de3cd53e345b4a15d17878c74587f02b11215716..5f1bf75d504836b7b8b9abe3e401117788143444 100644 (file)
@@ -299,6 +299,7 @@ class ArrayTest(_LiteralRoundTripFixture, fixtures.TablesTest):
 
 class BinaryTest(_LiteralRoundTripFixture, fixtures.TablesTest):
     __backend__ = True
+    __requires__ = ("binary_literals",)
 
     @classmethod
     def define_tables(cls, metadata):
@@ -1483,6 +1484,7 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
 
         return datatype, compare_value, p_s
 
+    @testing.requires.legacy_unconditional_json_extract
     @_index_fixtures(False)
     def test_index_typed_access(self, datatype, value):
         data_table = self.tables.data_table
@@ -1504,6 +1506,7 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
             eq_(roundtrip, compare_value)
             is_(type(roundtrip), type(compare_value))
 
+    @testing.requires.legacy_unconditional_json_extract
     @_index_fixtures(True)
     def test_index_typed_comparison(self, datatype, value):
         data_table = self.tables.data_table
@@ -1528,6 +1531,7 @@ class JSONTest(_LiteralRoundTripFixture, fixtures.TablesTest):
             # make sure we get a row even if value is None
             eq_(row, (compare_value,))
 
+    @testing.requires.legacy_unconditional_json_extract
     @_index_fixtures(True)
     def test_path_typed_comparison(self, datatype, value):
         data_table = self.tables.data_table