MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_rindex

Method test_rindex

Lib/test/string_tests.py:298–322  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

296 self.checkraises(TypeError, 'hello', 'index', 42)
297
298 def test_rindex(self):
299 self.checkequal(12, 'abcdefghiabc', 'rindex', '')
300 self.checkequal(3, 'abcdefghiabc', 'rindex', 'def')
301 self.checkequal(9, 'abcdefghiabc', 'rindex', 'abc')
302 self.checkequal(0, 'abcdefghiabc', 'rindex', 'abc', 0, -1)
303
304 self.checkraises(ValueError, 'abcdefghiabc', 'rindex', 'hib')
305 self.checkraises(ValueError, 'defghiabc', 'rindex', 'def', 1)
306 self.checkraises(ValueError, 'defghiabc', 'rindex', 'abc', 0, -1)
307 self.checkraises(ValueError, 'abcdefghi', 'rindex', 'ghi', 0, 8)
308 self.checkraises(ValueError, 'abcdefghi', 'rindex', 'ghi', 0, -1)
309
310 # to check the ability to pass None as defaults
311 self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a')
312 self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a', 4)
313 self.checkraises(ValueError, 'rrarrrrrrrrra', 'rindex', 'a', 4, 6)
314 self.checkequal(12, 'rrarrrrrrrrra', 'rindex', 'a', 4, None)
315 self.checkequal( 2, 'rrarrrrrrrrra', 'rindex', 'a', None, 6)
316
317 self.checkraises(TypeError, 'hello', 'rindex')
318
319 if self.contains_bytes:
320 self.checkraises(ValueError, 'hello', 'rindex', 42)
321 else:
322 self.checkraises(TypeError, 'hello', 'rindex', 42)
323
324 def test_find_periodic_pattern(self):
325 """Cover the special path for periodic patterns."""

Callers

nothing calls this directly

Calls 2

checkequalMethod · 0.95
checkraisesMethod · 0.95

Tested by

no test coverage detected