Skip to content

Commit

Permalink
Skip more tests which are expected to fail if vl-convert is not insta…
Browse files Browse the repository at this point in the history
…lled
  • Loading branch information
binste committed May 18, 2024
1 parent 035d225 commit 7338bed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
14 changes: 14 additions & 0 deletions tests/utils/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import pytest
from altair import vegalite_compilers, Chart

try:
import vl_convert as vlc # noqa: F401
except ImportError:
vlc = None


@pytest.fixture
def chart():
Expand All @@ -24,17 +29,26 @@ def assert_is_vega_spec(vega_spec):


def test_vegalite_compiler(chart):
if vlc is None:
pytest.skip("vl_convert is not installed")

vegalite_spec = chart.to_dict()
vega_spec = vegalite_compilers.get()(vegalite_spec)
assert_is_vega_spec(vega_spec)


def test_to_dict_with_format_vega(chart):
if vlc is None:
pytest.skip("vl_convert is not installed")

vega_spec = chart.to_dict(format="vega")
assert_is_vega_spec(vega_spec)


def test_to_json_with_format_vega(chart):
if vlc is None:
pytest.skip("vl_convert is not installed")

json_spec = chart.to_json(format="vega")
assert isinstance(json_spec, str)
spec = json.loads(json_spec)
Expand Down
7 changes: 3 additions & 4 deletions tests/utils/test_mimebundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ def vega_spec():
}


@pytest.mark.parametrize("engine", ["vl-convert", None])
def test_vegalite_to_vega_mimebundle(engine, vegalite_spec, vega_spec):
if engine == "vl-convert" and vlc is None:
def test_vegalite_to_vega_mimebundle(vegalite_spec, vega_spec):
if vlc is None:
pytest.skip("vl_convert not importable; cannot run mimebundle tests")

bundle = spec_to_mimebundle(
Expand All @@ -180,7 +179,7 @@ def test_vegalite_to_vega_mimebundle(engine, vegalite_spec, vega_spec):
vega_version=alt.VEGA_VERSION,
vegalite_version=alt.VEGALITE_VERSION,
vegaembed_version=alt.VEGAEMBED_VERSION,
engine=engine,
engine="vl-convert",
)

assert bundle == {"application/vnd.vega.v5+json": vega_spec}
Expand Down
3 changes: 3 additions & 0 deletions tests/vegalite/v5/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ def test_save_html(basic_chart, inline):


def test_to_url(basic_chart):
if vlc is None:
pytest.skip("vl_convert is not installed")

share_url = basic_chart.to_url()
expected_vegalite_encoding = "N4Igxg9gdgZglgcxALlANzgUwO4tJKAFzigFcJSBnAdTgBNCALFAZgAY2AacaYsiygAlMiRoVYcAvpO50AhoTl4QUOQFtMKEPMUBaAOwA2ABwAWFi1NyTcgEb7TtuabAswc-XTZhMczLdNDAEYQGRA1OQAnAGtlQgBPAAdNZBAnSNDuTChIOhIkVBAAD2V4TAAbOi0lbgTkrSgINRI5csyQeNKsSq1bEFqklJAAR1I5IjhFYjRNaW4AEkowRkwIrTFCRMpkAHodmYQ5ADoEScZSWyO4CB2llYj9zEPdcsnMfYBWI6D9I7YjgBWlGg-W0CjklEwhEoyh0cgMJnMlmsxjsDicLjcHi8Pj8AWCKAA2qAlKkAIKgvrIABMxhkJK0ACFKSgPh96SBSSAAMIs5DmDlcgAifIAnEFBVoAKJ84wSzgM1IAMT5HxYktSAHE+UFRRqQIJZfp9QBJVXUyQAXWkQA"

Expand Down

0 comments on commit 7338bed

Please sign in to comment.