]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
test: refactor test_table_tablespace to use testing.combinations
authorMiguel Grillo <miguel_grillo_orellana@hotmail.com>
Thu, 24 Oct 2024 17:50:38 +0000 (19:50 +0200)
committerMiguel Grillo <miguel_grillo_orellana@hotmail.com>
Thu, 24 Oct 2024 17:50:38 +0000 (19:50 +0200)
Refactored the test_table_tablespace to use testing.combinations for better maintainability and extensibility. This change reduces code repetition and makes it easier to add new test cases in the future.

test/dialect/oracle/test_compiler.py

index f723896e40b112dd4833c28c31874ee2b50342a4..972c60d6e7b49ee344bc4c759b5f71766251bc01 100644 (file)
@@ -1659,42 +1659,24 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             cast(column("foo"), d1), "CAST(foo AS DOUBLE PRECISION)"
         )
 
-    def test_table_tablespace(self):
+    @testing.combinations(
+        ("TEST_TABLESPACE", 'TABLESPACE "TEST_TABLESPACE"'),
+        ("test_tablespace", "TABLESPACE test_tablespace"),
+        ("TestTableSpace", 'TABLESPACE "TestTableSpace"'),
+        argnames="tablespace, expected_sql",
+    )
+    def test_table_tablespace(self, tablespace, expected_sql):
         m = MetaData()
 
         t = Table(
             "table1",
             m,
             Column("x", Integer),
-            oracle_tablespace="TEST_TABLESPACE",
-        )
-        t2 = Table(
-            "table2",
-            m,
-            Column("x", Integer),
-            oracle_tablespace="test_tablespace",
-        )
-        t3 = Table(
-            "table3",
-            m,
-            Column("x", Integer),
-            oracle_tablespace="TestTableSpace",
+            oracle_tablespace=tablespace,
         )
         self.assert_compile(
             schema.CreateTable(t),
-            "CREATE TABLE "
-            "table1 (x INTEGER) "
-            'TABLESPACE "TEST_TABLESPACE"',
-        )
-        self.assert_compile(
-            schema.CreateTable(t2),
-            "CREATE TABLE " "table2 (x INTEGER) " "TABLESPACE test_tablespace",
-        )
-        self.assert_compile(
-            schema.CreateTable(t3),
-            "CREATE TABLE "
-            "table3 (x INTEGER) "
-            'TABLESPACE "TestTableSpace"',
+            f"CREATE TABLE table1 (x INTEGER) {expected_sql}",
         )