Skip to content

Test failure in test_find_periodic_pattern in string_tests.py #105639

Description

@sweeneyde

A recent test failure:

FAIL: test_find_periodic_pattern (test.test_bytes.ByteArrayAsStringTest.test_find_periodic_pattern) (p='', text='')
Cover the special path for periodic patterns.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/string_tests.py", line 335, in test_find_periodic_pattern
    self.checkequal(reference_find(p, text),
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/string_tests.py", line 60, in checkequal
    self.assertEqual(
AssertionError: -1 != 0

The issue is reference_find:

        def reference_find(p, s):
            for i in range(len(s)):
                if s.startswith(p, i):
                    return i
            return -1

When s == p == '', we get for i in range(0), and then -1 is returned instead of the actual result which should be 0.

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions