-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add durations
to unittest
in 3.12
#10636
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
Conversation
This comment has been minimized.
This comment has been minimized.
stdlib/unittest/result.pyi
Outdated
|
||
_F = TypeVar("_F", bound=Callable[..., Any]) | ||
_DurationsType: TypeAlias = list[tuple[unittest.case.TestCase, float]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least collectedDurations
(ugh, camel case...) uses list[tuple[str, float]]
:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the docs are wrong: https://docs.python.org/3.12/library/unittest.html?highlight=collecteddurations#unittest.TestResult.collectedDurations
But even the tests use str
: https://github.com/python/cpython/blob/24b9bdd6eaf0b04667b6cd4c8154f7c7c10c2398/Lib/test/test_unittest/test_runner.py#L1402
I will send a PR to CPython.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap, I used docs for this type. Let's wait for your PR to land first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a deliberate change to fix a circular reference, they just forgot to update the docs: python/cpython#106888
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Diff from mypy_primer, showing the effect of this PR on open source code: tornado (https://github.com/tornadoweb/tornado)
+ tornado/test/runtests.py:72: error: Unused "type: ignore" comment [unused-ignore]
+ tornado/test/runtests.py:78: error: Unused "type: ignore" comment [unused-ignore]
|
Source commit: python/cpython@6883007