Skip to content

Improve AvailableResult.__repr__() #1015

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

Merged
merged 2 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions src/ansys/dpf/core/available_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ def __str__(self):
txt += f" {qualifier.__dict__()}\n"
return txt

def __repr__(self):
return f"AvailableResult<name={self.name}>"

@property
def name(self):
"""Result operator."""
Expand Down
9 changes: 8 additions & 1 deletion tests/test_resultinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ def test_get_result_resultinfo_from_index(model):


def test_print_result_info(model):
print(model.metadata.result_info)
str(model.metadata.result_info)


def test_repr_available_results_list(model):
ar = model.metadata.result_info.available_results
assert type(ar) is list
assert all([type(r) is dpf.core.result_info.available_result.AvailableResult for r in ar])
assert dpf.core.result_info.available_result.AvailableResult.__name__ in str(ar)


@pytest.mark.skipif(platform.system() == "Linux", reason="CFF not available for Linux InProcess.")
Expand Down