hy144328 commented on code in PR #41979:
URL: https://github.com/apache/superset/pull/41979#discussion_r3566809676


##########
tests/unit_tests/extensions/test_sqlalchemy.py:
##########
@@ -257,22 +261,27 @@ def test_dml(
         # Skip test if superset:// dialect can't be loaded (common in Docker)
         pytest.skip(f"Superset dialect not available: {e}")
 
-    conn = engine.connect()
-
-    conn.execute(text('INSERT INTO "database1.table1" (a, b) VALUES (3, 30)'))
-    results = conn.execute(text('SELECT * FROM "database1.table1"'))
-    assert list(results) == [(1, 10), (2, 20), (3, 30)]
-    conn.execute(text('UPDATE "database1.table1" SET b=35 WHERE a=3'))
-    results = conn.execute(text('SELECT * FROM "database1.table1"'))
-    assert list(results) == [(1, 10), (2, 20), (3, 35)]
-    conn.execute(text('DELETE FROM "database1.table1" WHERE b>20'))
-    results = conn.execute(text('SELECT * FROM "database1.table1"'))
-    assert list(results) == [(1, 10), (2, 20)]
-
-    with pytest.raises(ProgrammingError) as excinfo:
-        conn.execute(
-            text("""INSERT INTO "database2.table2" (a, b) VALUES (3, 
'thirty')""")
-        )
+    with engine.begin() as conn:
+        conn.execute(text('INSERT INTO "database1.table1" (a, b) VALUES (3, 
30)'))
+    with engine.connect() as conn:
+        results = conn.execute(text('SELECT * FROM "database1.table1"'))
+        assert list(results) == [(1, 10), (2, 20), (3, 30)]
+    with engine.begin() as conn:
+        conn.execute(text('UPDATE "database1.table1" SET b=35 WHERE a=3'))
+    with engine.connect() as conn:
+        results = conn.execute(text('SELECT * FROM "database1.table1"'))
+        assert list(results) == [(1, 10), (2, 20), (3, 35)]
+    with engine.begin() as conn:
+        conn.execute(text('DELETE FROM "database1.table1" WHERE b>20'))
+    with engine.connect() as conn:
+        results = conn.execute(text('SELECT * FROM "database1.table1"'))
+        assert list(results) == [(1, 10), (2, 20)]
+
+    with engine.begin() as conn:
+        with pytest.raises(ProgrammingError) as excinfo:

Review Comment:
   Nice to have but not a regression to the status quo.



##########
tests/unit_tests/extensions/test_sqlalchemy.py:
##########
@@ -178,9 +182,9 @@ def test_superset_limit(mocker: MockerFixture, app_context: 
None, table1: None)
         # Skip test if superset:// dialect can't be loaded (common in Docker)
         pytest.skip(f"Superset dialect not available: {e}")
 
-    conn = engine.connect()
-    results = conn.execute(text('SELECT * FROM "database1.table1"'))
-    assert list(results) == [(1, 10)]
+    with engine.connect() as conn:

Review Comment:
   Nice to have but not a regression to the status quo.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to