Skip to content

Commit

Permalink
Fix python3.11 build: remove deprecated, update traceback regex
Browse files Browse the repository at this point in the history
https://docs.python.org/3.11/whatsnew/3.11.html#enhanced-error-locations-in-tracebacks
Tracebacks were updated with `^^^^^..` locators surrounded by optional
`~~~..` so add an optional line that matches them into the traceback regex.

Removes unused variable and deprecated `assertRegexpMatches`.
  • Loading branch information
kontura authored and m-blaha committed Jan 12, 2022
1 parent a96abad commit 7772a95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/update_releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def _assert_prints(self, regex, stream):
"""
with tests.mock.patch(stream, io.BytesIO()) as mock:
yield
self.assertRegexpMatches(mock.getvalue(), regex)
self.assertRegex(mock.getvalue(), regex)

def _assert_iter_equal(self, actual, expected):
"""Test whether two iterables are equal.
Expand Down
4 changes: 2 additions & 2 deletions tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def mock_open(mock=None, data=None):
TRACEBACK_RE = re.compile(
r'(Traceback \(most recent call last\):\n'
r'(?: File "[^"\n]+", line \d+, in \w+\n'
r'(?: .+\n)?)+'
r'(?: .+\n)?'
r'(?: \s*\~*\^+\~*\n)?)+'
r'\S.*\n)')
REASONS = {
'hole': 'group',
Expand Down Expand Up @@ -585,7 +586,6 @@ class TestCase(unittest.TestCase):

if not dnf.pycomp.PY3:
assertCountEqual = unittest.TestCase.assertItemsEqual
assertRegex = unittest.TestCase.assertRegexpMatches

def assertEmpty(self, collection):
return self.assertEqual(len(collection), 0)
Expand Down

0 comments on commit 7772a95

Please sign in to comment.