Skip to content

Commit 792d67f

Browse files
author
chenyunliang520
committed
use context manager for cursor and ensure rollback in test_details
1 parent cce88aa commit 792d67f

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tests/test_column.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,14 @@ def skip_neg_scale(*args):
108108
],
109109
)
110110
def test_details(conn, type, precision, scale, dsize, isize):
111-
cur = conn.cursor()
112-
cur.execute(f"select null::{type}")
113-
col = cur.description[0]
111+
with conn.cursor() as cur:
112+
cur.execute(f"select null::{type}")
113+
col = cur.description[0]
114+
try:
115+
conn.rollback()
116+
except Exception:
117+
pass
118+
114119
assert type == col.type_display
115120
assert f" {type} " in (repr(col))
116121
assert col.precision == precision

0 commit comments

Comments
 (0)