File: test_errors.py

package info (click to toggle)
python-vega-datasets 0.9%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,128 kB
  • sloc: python: 623; makefile: 22
file content (30 lines) | stat: -rw-r--r-- 948 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pytest

from vega_datasets import data, local_data
from vega_datasets.core import Dataset


def test_undefined_dataset():
    with pytest.raises(AttributeError) as err:
        data("blahblahblah")
    assert str(err.value) == "No dataset named 'blahblahblah'"
    with pytest.raises(AttributeError) as err:
        local_data("blahblahblah")
    assert str(err.value) == "No dataset named 'blahblahblah'"


def test_undefined_infodict():
    with pytest.raises(ValueError) as err:
        Dataset._infodict("blahblahblah")
    assert str(err.value).startswith("No such dataset blahblahblah exists")


@pytest.mark.parametrize(
    "name", (set(Dataset.list_datasets()) - set(Dataset.list_local_datasets()))
)
def test_local_dataset_error(name):
    with pytest.raises(ValueError) as err:
        local_data(name)
    assert str(err.value).startswith(
        "'{0}' dataset is not available locally" "".format(name.replace("-", "_"))
    )