Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated Pack property names to match CSS #3033

Merged
merged 17 commits into from
Dec 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions core/tests/style/pack/test_deprecated_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ def delitem(obj, name):
@pytest.mark.parametrize(
"old_name, new_name, value, default",
[
# Travertino 0.3.0 doesn't support accessing a directional property via bracket
# notation.
# ("padding", "margin", (5, 5, 5, 5), (0, 0, 0, 0)),
("padding", "margin", (5, 5, 5, 5), (0, 0, 0, 0)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, it hadn't even occurred to me that I'd made this work. Nice catch! 🤣

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually wait, my attempt to deduplicate logic (by having __getitem__ call __getattribute__) had the happy accident of letting bracket notation access padding, but only because it entirely bypasses BaseStyle.__getitem__, which verifies valid property names. Now you can set style['bogus-name'] and it won't complain.

This mechanism is currently enforced in Travertino's tests, but not Toga's, so I missed it. I'll make a fix and add a test.

("padding_top", "margin_top", 5, 0),
("padding_right", "margin_right", 5, 0),
("padding_bottom", "margin_bottom", 5, 0),
Expand Down Expand Up @@ -70,21 +68,6 @@ def test_deprecated_properties(
assert get_fn(style, old_name) == default


def test_padding_margin():
"""Padding aliases margin (but can't be checked with bracket notation)."""
# Set the old name, then check the new name.
style = Pack()
with pytest.warns(DeprecationWarning):
style.padding = (5, 5, 5, 5)
assert style.margin == (5, 5, 5, 5)

# Set the new name, then check the old name.
style = Pack()
style.margin = (5, 5, 5, 5)
with pytest.warns(DeprecationWarning):
assert style.padding == (5, 5, 5, 5)


@pytest.mark.parametrize(
"direction, text_direction, alignment, align_items",
[
Expand Down