#!/bin/bash
set -e

# Kaleido is not packaged yet by debian
IGNORE_KALEIDO_FILE="--ignore=tests/test_optional/test_kaleido/test_kaleido.py"

# Skip test file which fails with pytz.exceptions.UnknownTimeZoneError
IGNORE_TZ_FILE="--ignore=tests/test_io/test_to_from_plotly_json.py"
SKIP_TZ_TESTS="test_trendline_on_timeseries or \
test_encode_as_datetime_with_localized_tz"

# Skip test files which depend on polars
IGNORE_POLARS_FILES="--ignore=tests/test_optional/test_px/test_px_input.py"

# Default render in tests/test_io/test_renderers.py is empty instead of
# browser, because we do not install any browers.
SKIP_TEST_DEFAULT_RENDERER="test_default_renderer"

# Skip tests that require anywidget, which is not packaged yet by debian.
SKIP_ANYWIDGET="test_from_json_output_type[FigureWidget or \
test_read_json_from_filelike[FigureWidget or \
test_read_json_from_pathlib[FigureWidget or \
test_read_json_from_file_string[FigureWidget"

# Skip a test regarding named colorscale that fails with
# AssertionError: assert [[0.0, 'rgb(2...4, 96)'], ...] == [[0.0,
# '#fcff...a52c60'], ...]
SKIP_NAMED_COLORSCALE="test_acceptance_named[Inferno_r]"

IGNORE_FILES="$IGNORE_KALEIDO_FILE $IGNORE_TZ_FILE $IGNORE_POLAR_FILES"
SKIP_EXPR="not ($SKIP_TEST_DEFAULT_RENDERER or $SKIP_ANYWIDGET or \
$SKIP_TZ_TESTS or $SKIP_NAMED_COLORSCALE)"

for python in $(py3versions -s); do
    $python -P -m pytest --disable-warnings $IGNORE_FILES -k "$SKIP_EXPR" tests
done
