File: test_alias.py

package info (click to toggle)
python-altair 5.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,952 kB
  • sloc: python: 25,649; sh: 14; makefile: 6
file content (21 lines) | stat: -rw-r--r-- 785 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
import pytest

import altair.vegalite.v5 as alt


def test_aliases():
    """Ensure that any aliases defined in `api.py` aren't colliding with names already defined in `core.py` or `channels.py`."""
    for alias in ["Bin", "Impute", "Title"]:
        # this test pass if the alias can resolve to its real name
        try:
            getattr(alt, alias)
        except AttributeError as err:
            raise AssertionError(f"cannot resolve '{alias}':, {err}") from err

        # this test fails if the alias match a colliding name in core
        with pytest.raises(AttributeError):
            getattr(alt.core, alias)

        # this test fails if the alias match a colliding name in channels
        with pytest.raises(AttributeError):
            getattr(alt.channels, alias)