@@ -773,18 +773,19 @@ async def test_transaction_commit(
773773 connection : Connection , create_drop_test_table_setup_teardown_async : Callable
774774) -> None :
775775 """Test transaction SQL statements with COMMIT."""
776+ table_name = create_drop_test_table_setup_teardown_async
776777 async with connection .cursor () as c :
777778 # Test successful transaction with COMMIT
778779 result = await c .execute ("BEGIN TRANSACTION" )
779780 assert result == 0 , "BEGIN TRANSACTION should return 0 rows"
780781
781- await c .execute ("INSERT INTO \" test_tbl \" VALUES (1, 'committed')" )
782+ await c .execute (f "INSERT INTO \" { table_name } \" VALUES (1, 'committed')" )
782783
783784 result = await c .execute ("COMMIT TRANSACTION" )
784785 assert result == 0 , "COMMIT TRANSACTION should return 0 rows"
785786
786787 # Verify the data was committed
787- await c .execute ('SELECT * FROM "test_tbl " WHERE id = 1' )
788+ await c .execute (f 'SELECT * FROM "{ table_name } " WHERE id = 1' )
788789 data = await c .fetchall ()
789790 assert len (data ) == 1 , "Committed data should be present"
790791 assert data [0 ] == [
@@ -797,23 +798,24 @@ async def test_transaction_rollback(
797798 connection : Connection , create_drop_test_table_setup_teardown_async : Callable
798799) -> None :
799800 """Test transaction SQL statements with ROLLBACK."""
801+ table_name = create_drop_test_table_setup_teardown_async
800802 async with connection .cursor () as c :
801803 # Test transaction with ROLLBACK
802804 result = await c .execute ("BEGIN" ) # Test short form
803805 assert result == 0 , "BEGIN should return 0 rows"
804806
805- await c .execute ("INSERT INTO \" test_tbl \" VALUES (1, 'rolled_back')" )
807+ await c .execute (f "INSERT INTO \" { table_name } \" VALUES (1, 'rolled_back')" )
806808
807809 # Verify data is visible within transaction
808- await c .execute ('SELECT * FROM "test_tbl " WHERE id = 1' )
810+ await c .execute (f 'SELECT * FROM "{ table_name } " WHERE id = 1' )
809811 data = await c .fetchall ()
810812 assert len (data ) == 1 , "Data should be visible within transaction"
811813
812814 result = await c .execute ("ROLLBACK" ) # Test short form
813815 assert result == 0 , "ROLLBACK should return 0 rows"
814816
815817 # Verify the data was rolled back
816- await c .execute ('SELECT * FROM "test_tbl " WHERE id = 1' )
818+ await c .execute (f 'SELECT * FROM "{ table_name } " WHERE id = 1' )
817819 data = await c .fetchall ()
818820 assert len (data ) == 0 , "Rolled back data should not be present"
819821
@@ -822,23 +824,24 @@ async def test_transaction_cursor_isolation(
822824 connection : Connection , create_drop_test_table_setup_teardown_async : Callable
823825) -> None :
824826 """Test that one cursor can't see another's data until it commits."""
827+ table_name = create_drop_test_table_setup_teardown_async
825828 cursor1 = connection .cursor ()
826829 cursor2 = connection .cursor ()
827830
828831 # Start transaction in cursor1 and insert data
829832 result = await cursor1 .execute ("BEGIN TRANSACTION" )
830833 assert result == 0 , "BEGIN TRANSACTION should return 0 rows"
831834
832- await cursor1 .execute ("INSERT INTO \" test_tbl \" VALUES (1, 'isolated_data')" )
835+ await cursor1 .execute (f "INSERT INTO \" { table_name } \" VALUES (1, 'isolated_data')" )
833836
834837 # Verify cursor1 can see its own uncommitted data
835- await cursor1 .execute ('SELECT * FROM "test_tbl " WHERE id = 1' )
838+ await cursor1 .execute (f 'SELECT * FROM "{ table_name } " WHERE id = 1' )
836839 data1 = await cursor1 .fetchall ()
837840 assert len (data1 ) == 1 , "Cursor1 should see its own uncommitted data"
838841 assert data1 [0 ] == [1 , "isolated_data" ], "Cursor1 data should match inserted values"
839842
840843 # Verify cursor2 cannot see cursor1's uncommitted data
841- await cursor2 .execute ('SELECT * FROM "test_tbl " WHERE id = 1' )
844+ await cursor2 .execute (f 'SELECT * FROM "{ table_name } " WHERE id = 1' )
842845 data2 = await cursor2 .fetchall ()
843846 assert len (data2 ) == 0 , "Cursor2 should not see cursor1's uncommitted data"
844847
@@ -847,7 +850,7 @@ async def test_transaction_cursor_isolation(
847850 assert result == 0 , "COMMIT TRANSACTION should return 0 rows"
848851
849852 # Now cursor2 should be able to see the committed data
850- await cursor2 .execute ('SELECT * FROM "test_tbl " WHERE id = 1' )
853+ await cursor2 .execute (f 'SELECT * FROM "{ table_name } " WHERE id = 1' )
851854 data2 = await cursor2 .fetchall ()
852855 assert len (data2 ) == 1 , "Cursor2 should see committed data after commit"
853856 assert data2 [0 ] == [1 , "isolated_data" ], "Cursor2 should see the committed data"
0 commit comments