Lines Matching refs:SUBSTR
39 SUBSTR = ' abc def ghi'
40 s = '-' * size + SUBSTR
42 self.assertEqual(caps[-len(SUBSTR):],
43 SUBSTR.capitalize())
44 self.assertEqual(caps.lstrip('-'), SUBSTR)
48 SUBSTR = ' abc def ghi'
49 s = SUBSTR.center(size)
51 lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2
54 self.assertEqual(s[lpadsize:-rpadsize], SUBSTR)
55 self.assertEqual(s.strip(), SUBSTR.strip())
59 SUBSTR = u' abc def ghi'
61 s = SUBSTR.center(size)
66 lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2
69 self.assertEqual(s[lpadsize:-rpadsize], SUBSTR)
70 self.assertEqual(s.strip(), SUBSTR.strip())
75 SUBSTR = ' abc def ghi'
76 s = '.' * size + SUBSTR
138 SUBSTR = ' abc def ghi'
139 s = '-' * size + SUBSTR
140 self.assertTrue(s.endswith(SUBSTR))
144 self.assertFalse(s.endswith('a' + SUBSTR))
145 self.assertFalse(SUBSTR.endswith(s))
161 SUBSTR = ' abc def ghi'
162 sublen = len(SUBSTR)
163 s = ''.join([SUBSTR, '-' * size, SUBSTR])
165 self.assertEqual(s.find(SUBSTR), 0)
167 self.assertEqual(s.find(SUBSTR, len(SUBSTR)), sublen + size)
168 self.assertEqual(s.find('i'), SUBSTR.find('i'))
170 sublen + size + SUBSTR.find('i'))
172 sublen + size + SUBSTR.find('i'))
177 SUBSTR = ' abc def ghi'
178 sublen = len(SUBSTR)
179 s = ''.join([SUBSTR, '-' * size, SUBSTR])
181 self.assertEqual(s.index(SUBSTR), 0)
183 self.assertEqual(s.index(SUBSTR, sublen), sublen + size)
184 self.assertEqual(s.index('i'), SUBSTR.index('i'))
186 sublen + size + SUBSTR.index('i'))
188 sublen + size + SUBSTR.index('i'))
193 SUBSTR = '123456'
194 s = 'a' * size + SUBSTR
201 SUBSTR = 'zzzzzzz'
202 s = 'a' * size + SUBSTR
209 SUBSTR = '123456'
210 s = '9' * size + SUBSTR
235 SUBSTR = '123456'
236 s = ''.join(['A', 'a' * size, SUBSTR])
263 SUBSTR = ' abc def ghi'
264 s = SUBSTR.ljust(size)
265 self.assertTrue(s.startswith(SUBSTR + ' '))
267 self.assertEqual(s.strip(), SUBSTR.strip())
278 SUBSTR = 'abc def ghi'
279 s = SUBSTR.rjust(size)
281 self.assertEqual(s.lstrip(), SUBSTR.lstrip())
283 s = SUBSTR.ljust(size)
302 SUBSTR = ' abc def ghi'
303 sublen = len(SUBSTR)
304 s = ''.join([SUBSTR, '-' * size, SUBSTR])
305 self.assertEqual(s.rfind(' '), sublen + size + SUBSTR.rfind(' '))
306 self.assertEqual(s.rfind(SUBSTR), sublen + size)
307 self.assertEqual(s.rfind(' ', 0, size), SUBSTR.rfind(' '))
308 self.assertEqual(s.rfind(SUBSTR, 0, sublen + size), 0)
309 self.assertEqual(s.rfind('i'), sublen + size + SUBSTR.rfind('i'))
310 self.assertEqual(s.rfind('i', 0, sublen), SUBSTR.rfind('i'))
312 SUBSTR.rfind('i'))
317 SUBSTR = ' abc def ghi'
318 sublen = len(SUBSTR)
319 s = ''.join([SUBSTR, '-' * size, SUBSTR])
321 sublen + size + SUBSTR.rindex(' '))
322 self.assertEqual(s.rindex(SUBSTR), sublen + size)
324 SUBSTR.rindex(' '))
325 self.assertEqual(s.rindex(SUBSTR, 0, sublen + size), 0)
327 sublen + size + SUBSTR.rindex('i'))
328 self.assertEqual(s.rindex('i', 0, sublen), SUBSTR.rindex('i'))
330 SUBSTR.rindex('i'))
335 SUBSTR = ' abc def ghi'
336 s = SUBSTR.ljust(size)
337 self.assertTrue(s.startswith(SUBSTR + ' '))
339 self.assertEqual(s.strip(), SUBSTR.strip())
343 SUBSTR = ' abc def ghi'
344 s = SUBSTR.ljust(size)
346 self.assertEqual(s.rstrip(), SUBSTR.rstrip())
348 s = SUBSTR.rjust(size)
361 SUBSTR = 'a' + ' ' * chunksize
362 s = SUBSTR * chunksize
393 SUBSTR = ' ' * chunksize + '\n' + ' ' * chunksize + '\r\n'
394 s = SUBSTR * chunksize
401 SUBSTR = ' abc def ghi'
402 s = '-' * size + SUBSTR
405 self.assertFalse(s.startswith(SUBSTR))
409 SUBSTR = ' abc def ghi '
410 s = SUBSTR.rjust(size)
412 self.assertEqual(s.strip(), SUBSTR.strip())
414 s = SUBSTR.ljust(size)
416 self.assertEqual(s.strip(), SUBSTR.strip())
420 SUBSTR = "aBcDeFG12.'\xa9\x00"
421 sublen = len(SUBSTR)
423 s = SUBSTR * repeats
426 self.assertEqual(s[:sublen * 3], SUBSTR.swapcase() * 3)
427 self.assertEqual(s[-sublen * 3:], SUBSTR.swapcase() * 3)
431 SUBSTR = 'SpaaHAaaAaham'
432 s = SUBSTR * (size // len(SUBSTR) + 2)
434 self.assertTrue(s.startswith((SUBSTR * 3).title()))
435 self.assertTrue(s.endswith(SUBSTR.lower() * 3))
440 SUBSTR = 'aZz.z.Aaz.'
441 sublen = len(SUBSTR)
443 s = SUBSTR * repeats
446 self.assertEqual(s[:sublen], SUBSTR.translate(trans))
447 self.assertEqual(s[-sublen:], SUBSTR.translate(trans))
461 SUBSTR = '-568324723598234'
462 s = SUBSTR.zfill(size)
463 self.assertTrue(s.endswith('0' + SUBSTR[1:]))
466 self.assertEqual(s.count('0'), size - len(SUBSTR))
546 SUBSTR = '0123456789'
547 sublen = len(SUBSTR)
548 s = SUBSTR * (size // sublen)
552 self.assertEqual(s[i], SUBSTR[0])
553 self.assertEqual(s[i:i + sublen], SUBSTR)
554 self.assertEqual(s[i:i + sublen:2], SUBSTR[::2])
557 SUBSTR[sublen::-3])
560 self.assertEqual(s[len(s) - 1], SUBSTR[-1])
561 self.assertEqual(s[-1], SUBSTR[-1])
562 self.assertEqual(s[len(s) - 10], SUBSTR[0])
563 self.assertEqual(s[-sublen], SUBSTR[0])
565 self.assertEqual(s[len(s) - 1:], SUBSTR[-1])
566 self.assertEqual(s[-1:], SUBSTR[-1])
567 self.assertEqual(s[len(s) - sublen:], SUBSTR)
568 self.assertEqual(s[-sublen:], SUBSTR)
579 SUBSTR = '0123456789'
581 s = ''.join([edge, SUBSTR, edge])
583 self.assertIn(SUBSTR, s)
584 self.assertNotIn(SUBSTR * 2, s)