-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for layer properties (#2811)
* Add test for layer properties * Update api.py Previous version worked for numbers but not for objects.
- Loading branch information
1 parent
6778e3c
commit ecf726d
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 |