File: test_layer_props.py

package info (click to toggle)
python-altair 5.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,952 kB
  • sloc: python: 25,649; sh: 14; makefile: 5
file content (23 lines) | stat: -rw-r--r-- 873 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pytest

import altair.vegalite.v5 as alt


def test_layer_props():
    """Beginning in Vega-Lite v5, the properties "height" and "width" were no longer allowed in a subchart within a LayerChart.  We check here that these are moved to the top level by Altair."""
    base = alt.Chart().mark_point()

    # Allowed
    base.properties(width=100) + base
    base.properties(width=100) + base.properties(height=200)
    base.properties(width=100) + base.properties(height=200, width=100)

    # Not allowed
    with pytest.raises(ValueError, match="inconsistent"):
        base.properties(width=100) + base.properties(width=200)

    # Check that the resulting LayerChart has the correct properties.
    c = base.properties(width=100) + base.properties(height=200, width=100)
    assert isinstance(c, alt.LayerChart)
    assert c.width == 100
    assert c.height == 200