]> 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)
committersqla-tester <sqla-tester@sqlalchemy.org>
Wed, 26 Feb 2025 10:06:16 +0000 (05:06 -0500)
<!-- 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

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 af466b2d56ef7a833e700fed6dafac2a55967f17..bddefc0d2a3f70a141721d9415fcf5d0970d749b 100644 (file)
@@ -1815,3 +1815,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 e280369fc086125d2f58f8d089f9673b21362764..efc66b44a97523c92bf56581ac9267c1eb006d2b 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 7f0b1a653de4e683cb0d12b80d47b0d69c192928..e6c4aa24f6a72873f68ba66d9f21ab7171bf96a7 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