Skip to content

Commit

Permalink
refactor(tests): move test_visualize.py to ibis/expr/tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kszucs authored and cpcloud committed Aug 11, 2023
1 parent 8531347 commit 46d74ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
Expand Up @@ -10,7 +10,7 @@
import ibis.expr.operations as ops
import ibis.expr.types as ir

pytest.importorskip("graphviz")
graphviz = pytest.importorskip("graphviz")

import ibis.expr.visualize as viz # noqa: E402
from ibis.expr import api # noqa: E402
Expand All @@ -36,10 +36,10 @@ def key(node):
.aggregate(amean=lambda f: f.a.mean(), bsum=lambda f: f.b.sum()),
],
)
def test_exprs(table, expr_func):
expr = expr_func(table)
def test_exprs(alltypes, expr_func):
expr = expr_func(alltypes)
graph = viz.to_graph(expr)
assert key(table.op()) in graph.source
assert key(alltypes.op()) in graph.source
assert key(expr.op()) in graph.source


Expand Down Expand Up @@ -98,7 +98,7 @@ def test_order_by():
assert key(expr.op()) in graph.source


def test_optional_graphviz_repr(monkeypatch, graphviz):
def test_optional_graphviz_repr(monkeypatch):
monkeypatch.setattr(ibis.options, "graphviz_repr", True)

t = ibis.table([("a", "int64"), ("b", "string"), ("c", "int32")])
Expand Down Expand Up @@ -148,7 +148,7 @@ def test_filter():
assert "predicates[1]" in graph.source


def test_html_escape(monkeypatch, graphviz):
def test_html_escape(monkeypatch):
monkeypatch.setattr(ibis.options, "graphviz_repr", True)
# Check that we correctly escape HTML <> characters in the graphviz
# representation. If an error is thrown, _repr_png_ returns None.
Expand Down
11 changes: 0 additions & 11 deletions ibis/tests/expr/conftest.py
Expand Up @@ -101,14 +101,3 @@ def pytest_pyfunc_call(pyfuncitem):
len(markers) == 1
), f"More than one xfail_unsupported marker found on test {pyfuncitem}"
pytest.xfail(reason=repr(e))


@pytest.fixture
def graphviz():
"""A fixture to ensure the graphviz library and CLI are installed"""
graphviz = pytest.importorskip("graphviz")
try:
graphviz.version()
except graphviz.ExecutableNotFound:
pytest.skip("graphviz CLI not installed")
return graphviz
2 changes: 1 addition & 1 deletion ibis/tests/expr/test_interactive.py
Expand Up @@ -33,7 +33,7 @@ def test_interactive_execute_on_repr(con):
assert len(con.executed_queries) > 0


def test_repr_png_is_none_in_interactive(con, graphviz):
def test_repr_png_is_none_in_interactive(con):
table = con.table("functional_alltypes")

with config.option_context("interactive", True):
Expand Down

0 comments on commit 46d74ee

Please sign in to comment.