Skip to content

Commit

Permalink
test(backends): use slightly more useful assertions for call count
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and jcrist committed Sep 10, 2024
1 parent 499fc03 commit a20d194
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions ibis/backends/snowflake/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,17 @@ def test_compile_does_not_make_requests(con, mocker):
expr = astronauts.year_of_selection.value_counts()
spy = mocker.spy(con.con, "cursor")
assert expr.compile() is not None
assert spy.call_count == 0
spy.assert_not_called()

t = ibis.memtable({"a": [1, 2, 3]})
assert con.compile(t) is not None
assert spy.call_count == 0
spy.assert_not_called()

assert ibis.to_sql(t, dialect="snowflake") is not None
assert spy.call_count == 0
spy.assert_not_called()

assert ibis.to_sql(expr) is not None
assert spy.call_count == 0
spy.assert_not_called()


# this won't be hit in CI, but folks can test locally
Expand Down
14 changes: 7 additions & 7 deletions ibis/backends/tests/test_dataframe_interchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ def test_dataframe_interchange_dataframe_methods_execute(con, alltypes, mocker):

df = t.__dataframe__()

assert to_pyarrow.call_count == 0
to_pyarrow.assert_not_called()
assert df.metadata == pa_df.metadata
assert df.num_rows() == pa_df.num_rows()
assert df.num_chunks() == pa_df.num_chunks()
assert len(list(df.get_chunks())) == df.num_chunks()
assert to_pyarrow.call_count == 1
to_pyarrow.assert_called_once()


@pytest.mark.notimpl(["flink"])
Expand All @@ -81,7 +81,7 @@ def test_dataframe_interchange_column_methods_execute(con, alltypes, mocker):
col = df.get_column(0)
pa_col = pa_df.get_column(0)

assert to_pyarrow.call_count == 0
to_pyarrow.assert_not_called()
assert col.size() == pa_col.size()
assert col.offset == pa_col.offset

Expand All @@ -91,7 +91,7 @@ def test_dataframe_interchange_column_methods_execute(con, alltypes, mocker):
assert col.num_chunks() == pa_col.num_chunks()
assert len(list(col.get_chunks())) == pa_col.num_chunks()
assert len(list(col.get_buffers())) == len(list(pa_col.get_buffers()))
assert to_pyarrow.call_count == 1
to_pyarrow.assert_called_once()

# Access another column doesn't execute
col2 = df.get_column(1)
Expand All @@ -111,13 +111,13 @@ def test_dataframe_interchange_select_after_execution_no_reexecute(
df = t.__dataframe__()

# An operation that requires loading data
assert to_pyarrow.call_count == 0
to_pyarrow.assert_not_called()
assert df.num_rows() == pa_df.num_rows()
assert to_pyarrow.call_count == 1
to_pyarrow.assert_called_once()

# Subselect columns doesn't reexecute
df2 = df.select_columns([1, 0])
pa_df2 = pa_df.select_columns([1, 0])
assert df2.num_rows() == pa_df2.num_rows()
assert df2.column_names() == pa_df2.column_names()
assert to_pyarrow.call_count == 1
to_pyarrow.assert_called_once()

0 comments on commit a20d194

Please sign in to comment.