FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-106368: Argument clinic tests: improve failure message when tests in `ClinicExternalTests` fail by AlexWaygood · Pull Request #107364 · python/cpython · GitHub

/ cpython Public

gh-106368: Argument clinic tests: improve failure message when tests in ClinicExternalTests fail - #107364

Merged
AlexWaygood merged 2 commits into
python:mainfrom
AlexWaygood:clinic-test-message
Jul 27, 2023
Merged

gh-106368: Argument clinic tests: improve failure message when tests in ClinicExternalTests fail#107364
AlexWaygood merged 2 commits into
python:mainfrom
AlexWaygood:clinic-test-message

Conversation

AlexWaygood commented Jul 27, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

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?)

bedevere-bot added awaiting core review tests Tests in the Lib/test dir labels Jul 27, 2023
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
Comment thread Lib/test/test_clinic.py Outdated
Comment thread Lib/test/test_clinic.py Outdated

erlend-aasland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks! (BTW, I love itertools!)

AlexWaygood enabled auto-merge (squash) July 27, 2023 23:20
AlexWaygood merged commit 76c26ea into python:main Jul 27, 2023

Copy link
Copy Markdown
Contributor

Thanks @AlexWaygood for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

Copy link
Copy Markdown

GH-107365 is a backport of this pull request to the 3.12 branch.

bedevere-bot removed the needs backport to 3.12 only security fixes label Jul 27, 2023

Copy link
Copy Markdown

GH-107366 is a backport of this pull request to the 3.11 branch.

bedevere-bot removed the needs backport to 3.11 only security fixes label Jul 27, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 27, 2023
…tests in `ClinicExternalTests` fail (pythonGH-107364)

(cherry picked from commit 76c26ea)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 27, 2023
…tests in `ClinicExternalTests` fail (pythonGH-107364)

(cherry picked from commit 76c26ea)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood deleted the clinic-test-message branch July 27, 2023 23:58
AlexWaygood added a commit that referenced this pull request Jul 28, 2023
… tests in `ClinicExternalTests` fail (GH-107364) (#107366)

gh-106368: Argument clinic tests: improve failure message when tests in `ClinicExternalTests` fail (GH-107364)
(cherry picked from commit 76c26ea)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
AlexWaygood added a commit that referenced this pull request Jul 28, 2023
… tests in `ClinicExternalTests` fail (GH-107364) (#107365)

gh-106368: Argument clinic tests: improve failure message when tests in `ClinicExternalTests` fail (GH-107364)
(cherry picked from commit 76c26ea)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL