Skip to content

gh-124130: Increase test coverage for \b and \B in regular expressions #124330

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

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Sep 23, 2024

@serhiy-storchaka serhiy-storchaka added tests Tests in the Lib/test dir needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Sep 23, 2024
@@ -883,31 +883,137 @@ def test_named_unicode_escapes(self):
self.checkPatternError(br'\N{LESS-THAN SIGN}', r'bad escape \N', 0)
self.checkPatternError(br'[\N{LESS-THAN SIGN}]', r'bad escape \N', 1)

def test_string_boundaries(self):
def test_word_boundaries(self):
Copy link
Member

Choose a reason for hiding this comment

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

[no change needed] I think we could use subtests to provide more informative context (basically what you've got in each # comment header) when a test fails? but this is already in keeping with the existing style of this file, so not a big deal. these seem to nicely encode the current behavior state of our re implementation.

Copy link
Member Author

Choose a reason for hiding this comment

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

The comments provide context to the reader of the code (so you will know where to add new tests), not when a test fails. The traceback already has all necessary context.

subTest() has two functions:

  • Provide more informative context when a test fails. This is especially useful when traceback does not identify the failed test (in a loop, with generated test data).
  • Allows to continue execution when a test fails and collect information about other test failures in one run. This works only when tests are independent and subTest() is well granulated.

It has a drawback -- the traceback is limited and can be less informative if subTest() is used in a helper.

@serhiy-storchaka serhiy-storchaka enabled auto-merge (squash) September 24, 2024 06:06
@serhiy-storchaka serhiy-storchaka merged commit b82f076 into python:main Sep 24, 2024
32 checks passed
@miss-islington-app
Copy link

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 24, 2024
…essions (pythonGH-124330)

(cherry picked from commit b82f076)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Sep 24, 2024

GH-124413 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Sep 24, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 24, 2024
…essions (pythonGH-124330)

(cherry picked from commit b82f076)

Co-authored-by: Serhiy Storchaka <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Sep 24, 2024

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

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Sep 24, 2024
serhiy-storchaka added a commit that referenced this pull request Sep 24, 2024
…ressions (GH-124330) (GH-124414)

(cherry picked from commit b82f076)

Co-authored-by: Serhiy Storchaka <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Oct 7, 2024
…ressions (GH-124330) (GH-124413)

(cherry picked from commit b82f076)

Co-authored-by: Serhiy Storchaka <[email protected]>
@serhiy-storchaka serhiy-storchaka deleted the test-re-word-boundaries branch October 21, 2024 13:41
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.

3 participants