Skip to content

Commit

Permalink
test: use con.list_tables for a more robust test
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Sep 16, 2024
1 parent d57c5ac commit 9da309c
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1727,7 +1727,6 @@ def test_insert_into_table_missing_columns(con, temp_table):
assert result == expected_result


@pytest.mark.notyet(["druid"], raises=AssertionError, reason="can't drop tables")
@pytest.mark.notyet(
["clickhouse", "flink"],
raises=AssertionError,
Expand All @@ -1742,30 +1741,24 @@ def test_insert_into_table_missing_columns(con, temp_table):
["bigquery"], raises=AssertionError, reason="test is flaky", strict=False
)
def test_memtable_cleanup(con):
memtables = con._memtables
memtable_count = len(memtables)

name = ibis.util.gen_name("temp_memtable")
t = ibis.memtable({"a": [1, 2, 3], "b": list("def")}, name=name)
op = t.op()

# the table isn't registered until we actually execute, and since we
# haven't yet executed anything, the table shouldn't be there
assert memtable_count == len(con._memtables)
assert name not in con.list_tables()

# execute, which means the table is registered and should be visible in
# con.list_tables()
con.execute(t.select("a"))
assert len(con._memtables) == memtable_count + 1
assert name in con.list_tables()

con.execute(t.select("b"))
assert len(con._memtables) == memtable_count + 1
assert name in con.list_tables()

# remove all references to `t`, which means the `op` shouldn't be reachable
# and the table should thus be dropped and no longer visible in
# con.list_tables()
del t, op
assert len(con._memtables) == memtable_count
# and the table should thus be dropped and no longer visible
del t
assert name not in con.list_tables()


Expand Down

0 comments on commit 9da309c

Please sign in to comment.