GeezerVison is showing github.com — gh-106368: Argument clinic tests: improve failure message when tests in `ClinicExternalTests` fail by AlexWaygood · Pull Request #107364 · python/cpython
Conversation
AlexWaygood
commented
Jul 27, 2023
•
edited by bedevere-bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Currently, if I apply this diff to Tools/clinic/clinic.py...
--- a/Tools/clinic/clinic.py
+++ b/Tools/clinic/clinic.py
@@ -4702,6 +4702,7 @@ def state_modulename_name(self, line: str | None) -> None:
fields = [x.strip() for x in existing.split('.')]
function_name = fields.pop()
module, cls = self.clinic._module_and_class(fields)
+ 1/0
for existing_function in (cls or module).functions:
if existing_function.name == function_name:
...then the argument clinic tests fail for me locally (good!), but the failure message is terrible (bad!):
======================================================================
FAIL: test_external (test.test_clinic.ClinicExternalTest.test_external)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 1410, in test_external
out = self.expect_success("-f", "-o", TESTFN, source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 1397, in expect_success
return self._do_test(*args)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 1389, in _do_test
self.fail("".join(proc.stderr))
AssertionError
----------------------------------------------------------------------
This change makes the error message much more helpful!
======================================================================
FAIL: test_external (test.test_clinic.ClinicExternalTest.test_external)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 1411, in test_external
out = self.expect_success("-f", "-o", TESTFN, source)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 1398, in expect_success
return self._do_test(*args)
^^^^^^^^^^^^^^^^^^^^
File "C:\Users\alexw\coding\cpython\Lib\test\test_clinic.py", line 1390, in _do_test
self.fail("".join(itertools.chain(proc.stdout, proc.stderr)))
AssertionError: Error in file "C:\Users\alexw\coding\cpython\Lib\test\clinic.test.c" on line 117:
Exception raised during parsing:
Traceback (most recent call last):
File "C:\Users\alexw\coding\cpython\Tools\clinic\clinic.py", line 2244, in parse
parser.parse(block)
File "C:\Users\alexw\coding\cpython\Tools\clinic\clinic.py", line 4608, in parse
self.state(line)
File "C:\Users\alexw\coding\cpython\Tools\clinic\clinic.py", line 4666, in state_dsl_start
self.next(self.state_modulename_name, line)
File "C:\Users\alexw\coding\cpython\Tools\clinic\clinic.py", line 4648, in next
self.state(line)
File "C:\Users\alexw\coding\cpython\Tools\clinic\clinic.py", line 4705, in state_modulename_name
1/0
~^~
ZeroDivisionError: division by zero
----------------------------------------------------------------------
(@erlend-aasland do you see the same thing locally? Am I seeing something different because I'm using a Windows box?)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
AlexWaygood
changed the title
Argument clinic tests: improve failure message when tests in ClinicExternalTests fail
gh-106368: Argument clinic tests: improve failure message when tests in ClinicExternalTests fail
Jul 27, 2023
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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! (BTW, I love itertools!)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
AlexWaygood reacted with laugh emoji
|
Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|