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

Improved AppTest/ElementTree formatting #7658

Merged
merged 8 commits into from Nov 3, 2023

Conversation

AnOctopus
Copy link
Contributor

Describe your changes

Make AppTest and ElementTree reprs into an indented tree format, to aid debugging

GitHub Issue Link (if applicable)

Testing Plan

Manually tested, difficult to write reasonable tests for.


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

lib/streamlit/testing/v1/element_tree.py Outdated Show resolved Hide resolved
lib/streamlit/testing/v1/element_tree.py Fixed Show resolved Hide resolved
lib/streamlit/testing/v1/app_test.py Outdated Show resolved Hide resolved
Comment on lines 1567 to 1578
defaults: list[Any] = [None, "", False, [], set(), dict()]

if dataclasses.is_dataclass(self):
fields_vals = (
(f.name, getattr(self, f.name))
for f in dataclasses.fields(self)
if f.repr
and getattr(self, f.name) != f.default
and getattr(self, f.name) not in defaults
)
else:
fields_vals = ((f, v) for (f, v) in self.__dict__.items() if v not in defaults)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: might be worth adding a comment above defaults mentioning that empty lists/sets/dicts compare to be equal -- I thought this wouldn't work when first reading through this before double checking that they do

@sfc-gh-jcarroll
Copy link
Collaborator

@AnOctopus mind posting an output (copy/paste or screenshot) about how this looks? Exciting! 🚀

@AnOctopus
Copy link
Contributor Author

Screenshot

@AnOctopus AnOctopus merged commit 2a5a59a into streamlit:develop Nov 3, 2023
43 checks passed
@AnOctopus AnOctopus deleted the feat/better-tree-printing branch November 3, 2023 18:10
eric-skydio pushed a commit to eric-skydio/streamlit that referenced this pull request Dec 20, 2023
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Mar 22, 2024
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants