From d3af03544d7e47e792db422796a92c978634a1a8 Mon Sep 17 00:00:00 2001 From: franz haas Date: Tue, 16 Jan 2024 17:19:11 +0100 Subject: [PATCH] - added win tests --- .github/workflows/win.yml | 73 +++++++++++++++++++++++++++++++++++ tests/vegalite/v5/test_api.py | 6 ++- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/win.yml diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml new file mode 100644 index 0000000000..3181529260 --- /dev/null +++ b/.github/workflows/win.yml @@ -0,0 +1,73 @@ +name: test_on_windows + +on: [push, pull_request] + +jobs: + build: + runs-on: windows-latest + strategy: + matrix: + python-version: ["3.8","3.12"] + jsonschema-version: ["3.0", "latest"] + name: py ${{ matrix.python-version }} js ${{ matrix.jsonschema-version }} + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + # - name: Set Up Chromedriver + # run: | + # sudo apt-get update + # sudo apt-get --only-upgrade install google-chrome-stable + # sudo apt-get -yqq install chromium-chromedriver + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install .[dev] + # pip install "selenium<4.3.0" + # pip install altair_saver + - name: Install specific jsonschema + # Only have to execute this if we don't want the latest jsonschema version + if: ${{ matrix.jsonschema-version != 'latest' }} + run: | + pip install jsonschema==${{ matrix.jsonschema-version }} + - name: Maybe uninstall optional dependencies + # We uninstall pyarrow and vegafusion for one job to test that we have not + # accidentally introduced a hard dependency on these libraries. + # Uninstalling for Python 3.8 is an arbitrary choice. + # Also see https://github.com/altair-viz/altair/pull/3114 + if: ${{ matrix.python-version == '3.8' }} + run: | + pip uninstall -y pyarrow vegafusion vegafusion-python-embed + - name: Maybe install lowest supported pandas version + # We install the lowest supported pandas version for one job to test that + # it still works. Downgrade to the oldest versions of pandas and numpy that include + # Python 3.8 wheels, so only run this job for Python 3.8 + if: ${{ matrix.python-version == '3.8' }} + run: | + pip install pandas==0.25.3 numpy==1.17.5 + - name: Test with pytest + run: | + pytest --doctest-modules tests + # - name: Selected tests without vl-convert-python + # run: | + # pip uninstall vl-convert-python --yes + # pytest -m save_engine --doctest-modules tests + # - name: Selected tests without vl-convert-python and altair_saver + # run: | + # pip uninstall altair_saver --yes + # pytest -m save_engine --doctest-modules tests + - name: Selected tests with vl-convert-python and without altair_saver + run: | + # pip install vl-convert-python + pytest -m save_engine --doctest-modules tests + - name: Validate Vega-Lite schema + run: | + # We install all 'format' dependencies of jsonschema as check-jsonschema + # only does the 'format' checks which are installed. + # We can always use the latest jsonschema version here. + # uri-reference check is disabled as the URIs in the Vega-Lite schema do + # not conform RFC 3986. + pip install 'jsonschema[format]' check-jsonschema --upgrade + check-jsonschema --check-metaschema altair/vegalite/v5/schema/vega-lite-schema.json --disable-formats uri-reference diff --git a/tests/vegalite/v5/test_api.py b/tests/vegalite/v5/test_api.py index af963be7d9..78513b260b 100644 --- a/tests/vegalite/v5/test_api.py +++ b/tests/vegalite/v5/test_api.py @@ -363,7 +363,7 @@ def test_save(format, engine, basic_chart): # Only test inline=False as altair_viewer is required for inline=True # but that package has not yet been released with support for Altair 5 -@pytest.mark.parametrize("inline", [False]) +@pytest.mark.parametrize("inline", [False, True]) def test_save_html(basic_chart, inline): out = io.StringIO() basic_chart.save(out, format="html", inline=inline) @@ -379,6 +379,10 @@ def test_save_html(basic_chart, inline): assert 'src="https://cdn.jsdelivr.net/npm/vega-lite@5' in content assert 'src="https://cdn.jsdelivr.net/npm/vega-embed@6' in content + with tempfile.TemporaryDirectory() as tdir: + basic_chart.save(tdir + "/res.html", format="html", inline=inline) + + def test_to_url(basic_chart): share_url = basic_chart.to_url()