Title: Python 3.11 improved tracebacks break the tests · Issue #2451 · pre-commit/pre-commit · GitHub
Open Graph Title: Python 3.11 improved tracebacks break the tests · Issue #2451 · pre-commit/pre-commit
X Title: Python 3.11 improved tracebacks break the tests · Issue #2451 · pre-commit/pre-commit
Description: search tried in the issue tracker 3.11 describe your issue When we rebuild pre-commit in Fedora 37 with Python 3.11, we see the following failures: =================================== FAILURES =================================== ________...
Open Graph Description: search tried in the issue tracker 3.11 describe your issue When we rebuild pre-commit in Fedora 37 with Python 3.11, we see the following failures: =================================== FAILURES ====...
X Description: search tried in the issue tracker 3.11 describe your issue When we rebuild pre-commit in Fedora 37 with Python 3.11, we see the following failures: =================================== FAILURES ====...
Opengraph URL: https://github.com/pre-commit/pre-commit/issues/2451
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Python 3.11 improved tracebacks break the tests","articleBody":"### search tried in the issue tracker\n\n3.11\n\n### describe your issue\n\nWhen we rebuild pre-commit in Fedora 37 with Python 3.11, we see the following failures:\r\n\r\n```\r\n=================================== FAILURES ===================================\r\n________________________ test_error_handler_fatal_error ________________________\r\nmocked_log_and_exit = \u003cMagicMock name='_log_and_exit' id='140736176514768'\u003e\r\n def test_error_handler_fatal_error(mocked_log_and_exit):\r\n exc = FatalError('just a test')\r\n with error_handler.error_handler():\r\n raise exc\r\n \r\n mocked_log_and_exit.assert_called_once_with(\r\n 'An error has occurred',\r\n 1,\r\n exc,\r\n # Tested below\r\n mock.ANY,\r\n )\r\n \r\n pattern = re_assert.Matches(\r\n r'Traceback \\(most recent call last\\):\\n'\r\n r' File \".+pre_commit.error_handler.py\", line \\d+, in error_handler\\n'\r\n r' yield\\n'\r\n r' File \".+tests.error_handler_test.py\", line \\d+, '\r\n r'in test_error_handler_fatal_error\\n'\r\n r' raise exc\\n'\r\n r'(pre_commit\\.errors\\.)?FatalError: just a test\\n',\r\n )\r\n\u003e pattern.assert_matches(mocked_log_and_exit.call_args[0][3])\r\ntests/error_handler_test.py:53: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\nself = Matches('Traceback \\\\(most recent call last\\\\):\\\\n File \".+pre_commit.error_handler.py\", line \\\\d+, in error_handler\\...st_error_handler_fatal_error\r\n #\u003e raise exc\r\n #\u003e ^^^^^^^^^\r\n #\u003e pre_commit.errors.FatalError: just a test\r\ns = 'Traceback (most recent call last):\\n File \"/builddir/build/BUILD/pre-commit-2.19.0/pre_commit/error_handler.py\", lin... line 34, in test_error_handler_fatal_error\\n raise exc\\n ^^^^^^^^^\\npre_commit.errors.FatalError: just a test\\n'\r\n def assert_matches(self, s: str) -\u003e None:\r\n\u003e assert self == s, self._fail\r\nE AssertionError: regex failed to match at:\r\nE \r\nE \u003e Traceback (most recent call last):\r\nE \u003e File \"/builddir/build/BUILD/pre-commit-2.19.0/pre_commit/error_handler.py\", line 73, in error_handler\r\nE \u003e yield\r\nE \u003e ^^^^^\r\nE ^\r\nE \u003e File \"/builddir/build/BUILD/pre-commit-2.19.0/tests/error_handler_test.py\", line 34, in test_error_handler_fatal_error\r\nE \u003e raise exc\r\nE \u003e ^^^^^^^^^\r\nE \u003e pre_commit.errors.FatalError: just a test\r\n/usr/lib/python3.11/site-packages/re_assert.py:63: AssertionError\r\n______________________ test_error_handler_uncaught_error _______________________\r\nmocked_log_and_exit = \u003cMagicMock name='_log_and_exit' id='140736174639952'\u003e\r\n def test_error_handler_uncaught_error(mocked_log_and_exit):\r\n exc = ValueError('another test')\r\n with error_handler.error_handler():\r\n raise exc\r\n \r\n mocked_log_and_exit.assert_called_once_with(\r\n 'An unexpected error has occurred',\r\n 3,\r\n exc,\r\n # Tested below\r\n mock.ANY,\r\n )\r\n pattern = re_assert.Matches(\r\n r'Traceback \\(most recent call last\\):\\n'\r\n r' File \".+pre_commit.error_handler.py\", line \\d+, in error_handler\\n'\r\n r' yield\\n'\r\n r' File \".+tests.error_handler_test.py\", line \\d+, '\r\n r'in test_error_handler_uncaught_error\\n'\r\n r' raise exc\\n'\r\n r'ValueError: another test\\n',\r\n )\r\n\u003e pattern.assert_matches(mocked_log_and_exit.call_args[0][3])\r\ntests/error_handler_test.py:77: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\nself = Matches('Traceback \\\\(most recent call last\\\\):\\\\n File \".+pre_commit.error_handler.py\", line \\\\d+, in error_handler\\...line 59, in test_error_handler_uncaught_error\r\n #\u003e raise exc\r\n #\u003e ^^^^^^^^^\r\n #\u003e ValueError: another test\r\ns = 'Traceback (most recent call last):\\n File \"/builddir/build/BUILD/pre-commit-2.19.0/pre_commit/error_handler.py\", lin...dler_test.py\", line 59, in test_error_handler_uncaught_error\\n raise exc\\n ^^^^^^^^^\\nValueError: another test\\n'\r\n def assert_matches(self, s: str) -\u003e None:\r\n\u003e assert self == s, self._fail\r\nE AssertionError: regex failed to match at:\r\nE \r\nE \u003e Traceback (most recent call last):\r\nE \u003e File \"/builddir/build/BUILD/pre-commit-2.19.0/pre_commit/error_handler.py\", line 73, in error_handler\r\nE \u003e yield\r\nE \u003e ^^^^^\r\nE ^\r\nE \u003e File \"/builddir/build/BUILD/pre-commit-2.19.0/tests/error_handler_test.py\", line 59, in test_error_handler_uncaught_error\r\nE \u003e raise exc\r\nE \u003e ^^^^^^^^^\r\nE \u003e ValueError: another test\r\n/usr/lib/python3.11/site-packages/re_assert.py:63: AssertionError\r\n_____________________ test_error_handler_keyboardinterrupt _____________________\r\nmocked_log_and_exit = \u003cMagicMock name='_log_and_exit' id='140736174647248'\u003e\r\n def test_error_handler_keyboardinterrupt(mocked_log_and_exit):\r\n exc = KeyboardInterrupt()\r\n with error_handler.error_handler():\r\n raise exc\r\n \r\n mocked_log_and_exit.assert_called_once_with(\r\n 'Interrupted (^C)',\r\n 130,\r\n exc,\r\n # Tested below\r\n mock.ANY,\r\n )\r\n pattern = re_assert.Matches(\r\n r'Traceback \\(most recent call last\\):\\n'\r\n r' File \".+pre_commit.error_handler.py\", line \\d+, in error_handler\\n'\r\n r' yield\\n'\r\n r' File \".+tests.error_handler_test.py\", line \\d+, '\r\n r'in test_error_handler_keyboardinterrupt\\n'\r\n r' raise exc\\n'\r\n r'KeyboardInterrupt\\n',\r\n )\r\n\u003e pattern.assert_matches(mocked_log_and_exit.call_args[0][3])\r\ntests/error_handler_test.py:101: \r\n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r\nself = Matches('Traceback \\\\(most recent call last\\\\):\\\\n File \".+pre_commit.error_handler.py\", line \\\\d+, in error_handler\\...y\", line 83, in test_error_handler_keyboardinterrupt\r\n #\u003e raise exc\r\n #\u003e ^^^^^^^^^\r\n #\u003e KeyboardInterrupt\r\ns = 'Traceback (most recent call last):\\n File \"/builddir/build/BUILD/pre-commit-2.19.0/pre_commit/error_handler.py\", lin..._handler_test.py\", line 83, in test_error_handler_keyboardinterrupt\\n raise exc\\n ^^^^^^^^^\\nKeyboardInterrupt\\n'\r\n def assert_matches(self, s: str) -\u003e None:\r\n\u003e assert self == s, self._fail\r\nE AssertionError: regex failed to match at:\r\nE \r\nE \u003e Traceback (most recent call last):\r\nE \u003e File \"/builddir/build/BUILD/pre-commit-2.19.0/pre_commit/error_handler.py\", line 73, in error_handler\r\nE \u003e yield\r\nE \u003e ^^^^^\r\nE ^\r\nE \u003e File \"/builddir/build/BUILD/pre-commit-2.19.0/tests/error_handler_test.py\", line 83, in test_error_handler_keyboardinterrupt\r\nE \u003e raise exc\r\nE \u003e ^^^^^^^^^\r\nE \u003e KeyboardInterrupt\r\n/usr/lib/python3.11/site-packages/re_assert.py:63: AssertionError\r\n```\r\n\r\nI believe all of them are caused by extra `^^^^^^^^^` in the tracebacks.\r\n\r\nI might be able to submit a PR for this if you are interested.\n\n### pre-commit --version\n\n2.19.0\n\n### .pre-commit-config.yaml\n\n```yaml\nnot relevant\n```\n\n\n### ~/.cache/pre-commit/pre-commit.log (if present)\n\n_No response_","author":{"url":"https://github.com/hroncok","@type":"Person","name":"hroncok"},"datePublished":"2022-07-09T18:01:01.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2451/pre-commit/issues/2451"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d9cc7504-0865-b369-d6d2-be198811c248 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CBAE:2010FD:F58882:13DCDCE:6990C4E0 |
| html-safe-nonce | b717e0690522ff586101d91209dbda3881a882f30a6b3d42b1b36e168a0af815 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkFFOjIwMTBGRDpGNTg4ODI6MTNEQ0RDRTo2OTkwQzRFMCIsInZpc2l0b3JfaWQiOiI0NzkyODc2ODQzNDQyMTYwODY0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 71cf4f26766e98f33cca68c08e9bedce2bd6a35aa49270e28f69e5f358b382e8 |
| hovercard-subject-tag | issue:1299735279 |
| github-keyboard-shortcuts | repository,issues,commits,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/pre-commit/pre-commit/2451/issue_layout |
| twitter:image | https://opengraph.githubassets.com/61ad676e8be14ad31db112ad1e471c696a1fd4d485f043bd8d991c7dc0589ac5/pre-commit/pre-commit/issues/2451 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/61ad676e8be14ad31db112ad1e471c696a1fd4d485f043bd8d991c7dc0589ac5/pre-commit/pre-commit/issues/2451 |
| og:image:alt | search tried in the issue tracker 3.11 describe your issue When we rebuild pre-commit in Fedora 37 with Python 3.11, we see the following failures: =================================== FAILURES ====... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | hroncok |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/pre-commit/pre-commit git https://github.com/pre-commit/pre-commit.git |
| octolytics-dimension-user_id | 6943086 |
| octolytics-dimension-user_login | pre-commit |
| octolytics-dimension-repository_id | 17689377 |
| octolytics-dimension-repository_nwo | pre-commit/pre-commit |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 17689377 |
| octolytics-dimension-repository_network_root_nwo | pre-commit/pre-commit |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width