Use bayeslite.bayesdb_open in a with-block in test_guess.
@@ -129,11 +129,12 @@ def test_guess_stattypes():
['numerical', 'numerical']
def test_guess_population():
- bdb = bayeslite.bayesdb_open()
+ with bayeslite.bayesdb_open() as bdb:
bdb.sql_execute('CREATE TABLE t(x NUMERIC, y NUMERIC, z NUMERIC)')
a_z = range(ord('a'), ord('z') + 1)
aa_zz = ((c, d) for c in a_z for d in a_z)
- data = ((chr(c) + chr(d), (c + d) % 2, math.sqrt(c + d)) for c, d in aa_zz)
+ data = ((chr(c) + chr(d), (c + d) % 2, math.sqrt(c + d))
+ for c, d in aa_zz)
for row in data:
bdb.sql_execute('INSERT INTO t (x, y, z) VALUES (?, ?, ?)', row)
with pytest.raises(ValueError):
@@ -150,11 +151,12 @@ def test_guess_population():
]
def test_guess_schema():
- bdb = bayeslite.bayesdb_open()
+ with bayeslite.bayesdb_open() as bdb:
bdb.sql_execute('CREATE TABLE t(x NUMERIC, y NUMERIC, z NUMERIC)')
a_z = range(ord('a'), ord('z') + 1)
aa_zz = ((c, d) for c in a_z for d in a_z)
- data = ((chr(c) + chr(d), (c + d) % 2, math.sqrt(c + d)) for c, d in aa_zz)
+ data = ((chr(c) + chr(d), (c + d) % 2, math.sqrt(c + d))
+ for c, d in aa_zz)
for row in data:
bdb.sql_execute('INSERT INTO t (x, y, z) VALUES (?, ?, ?)', row)
with pytest.raises(BQLError):
