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

Improve approx scalar repr method for better readability #12665

Merged
merged 17 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 5 additions & 1 deletion src/_pytest/python_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,11 @@
# If a sensible tolerance can't be calculated, self.tolerance will
# raise a ValueError. In this case, display '???'.
try:
vetted_tolerance = f"{self.tolerance:.1e}"
if self.tolerance >= 1e-3 and self.tolerance < 1e3:
fazeelghafoor marked this conversation as resolved.
Show resolved Hide resolved
vetted_tolerance = f"{self.tolerance:n}"

Check warning on line 410 in src/_pytest/python_api.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/python_api.py#L410

Added line #L410 was not covered by tests
else:
vetted_tolerance = f"{self.tolerance:.1e}"

Check warning on line 412 in src/_pytest/python_api.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/python_api.py#L412

Added line #L412 was not covered by tests

if (
isinstance(self.expected, Complex)
and self.expected.imag
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
del sys.last_value
del sys.last_traceback
if sys.version_info >= (3, 12, 0):
del sys.last_exc
del sys.last_exc # type: ignore[attr-defined]

Check warning on line 170 in src/_pytest/runner.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/runner.py#L170

Added line #L170 was not covered by tests
except AttributeError:
pass
try:
Expand All @@ -177,7 +177,7 @@
sys.last_type = type(e)
sys.last_value = e
if sys.version_info >= (3, 12, 0):
sys.last_exc = e
sys.last_exc = e # type: ignore[attr-defined]

Check warning on line 180 in src/_pytest/runner.py

View check run for this annotation

Codecov / codecov/patch

src/_pytest/runner.py#L180

Added line #L180 was not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this type ignores are unused in the CI (see pre-commit job).

assert e.__traceback__ is not None
# Skip *this* frame
sys.last_traceback = e.__traceback__.tb_next
Expand Down
Loading