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
137 SUBSTR = ' abc def ghi'
138 s = '-' * size + SUBSTR
139 self.assertTrue(s.endswith(SUBSTR))
143 self.assertFalse(s.endswith('a' + SUBSTR))
144 self.assertFalse(SUBSTR.endswith(s))
160 SUBSTR = ' abc def ghi'
161 sublen = len(SUBSTR)
162 s = ''.join([SUBSTR, '-' * size, SUBSTR])
164 self.assertEqual(s.find(SUBSTR), 0)
166 self.assertEqual(s.find(SUBSTR, len(SUBSTR)), sublen + size)
167 self.assertEqual(s.find('i'), SUBSTR.find('i'))
169 sublen + size + SUBSTR.find('i'))
171 sublen + size + SUBSTR.find('i'))
176 SUBSTR = ' abc def ghi'
177 sublen = len(SUBSTR)
178 s = ''.join([SUBSTR, '-' * size, SUBSTR])
180 self.assertEqual(s.index(SUBSTR), 0)
182 self.assertEqual(s.index(SUBSTR, sublen), sublen + size)
183 self.assertEqual(s.index('i'), SUBSTR.index('i'))
185 sublen + size + SUBSTR.index('i'))
187 sublen + size + SUBSTR.index('i'))
192 SUBSTR = '123456'
193 s = 'a' * size + SUBSTR
200 SUBSTR = 'zzzzzzz'
201 s = 'a' * size + SUBSTR
208 SUBSTR = '123456'
209 s = '9' * size + SUBSTR
234 SUBSTR = '123456'
235 s = ''.join(['A', 'a' * size, SUBSTR])
262 SUBSTR = ' abc def ghi'
263 s = SUBSTR.ljust(size)
264 self.assertTrue(s.startswith(SUBSTR + ' '))
266 self.assertEqual(s.strip(), SUBSTR.strip())
277 SUBSTR = 'abc def ghi'
278 s = SUBSTR.rjust(size)
280 self.assertEqual(s.lstrip(), SUBSTR.lstrip())
282 s = SUBSTR.ljust(size)
301 SUBSTR = ' abc def ghi'
302 sublen = len(SUBSTR)
303 s = ''.join([SUBSTR, '-' * size, SUBSTR])
304 self.assertEqual(s.rfind(' '), sublen + size + SUBSTR.rfind(' '))
305 self.assertEqual(s.rfind(SUBSTR), sublen + size)
306 self.assertEqual(s.rfind(' ', 0, size), SUBSTR.rfind(' '))
307 self.assertEqual(s.rfind(SUBSTR, 0, sublen + size), 0)
308 self.assertEqual(s.rfind('i'), sublen + size + SUBSTR.rfind('i'))
309 self.assertEqual(s.rfind('i', 0, sublen), SUBSTR.rfind('i'))
311 SUBSTR.rfind('i'))
316 SUBSTR = ' abc def ghi'
317 sublen = len(SUBSTR)
318 s = ''.join([SUBSTR, '-' * size, SUBSTR])
320 sublen + size + SUBSTR.rindex(' '))
321 self.assertEqual(s.rindex(SUBSTR), sublen + size)
323 SUBSTR.rindex(' '))
324 self.assertEqual(s.rindex(SUBSTR, 0, sublen + size), 0)
326 sublen + size + SUBSTR.rindex('i'))
327 self.assertEqual(s.rindex('i', 0, sublen), SUBSTR.rindex('i'))
329 SUBSTR.rindex('i'))
334 SUBSTR = ' abc def ghi'
335 s = SUBSTR.ljust(size)
336 self.assertTrue(s.startswith(SUBSTR + ' '))
338 self.assertEqual(s.strip(), SUBSTR.strip())
342 SUBSTR = ' abc def ghi'
343 s = SUBSTR.ljust(size)
345 self.assertEqual(s.rstrip(), SUBSTR.rstrip())
347 s = SUBSTR.rjust(size)
360 SUBSTR = 'a' + ' ' * chunksize
361 s = SUBSTR * chunksize
392 SUBSTR = ' ' * chunksize + '\n' + ' ' * chunksize + '\r\n'
393 s = SUBSTR * chunksize
400 SUBSTR = ' abc def ghi'
401 s = '-' * size + SUBSTR
404 self.assertFalse(s.startswith(SUBSTR))
408 SUBSTR = ' abc def ghi '
409 s = SUBSTR.rjust(size)
411 self.assertEqual(s.strip(), SUBSTR.strip())
413 s = SUBSTR.ljust(size)
415 self.assertEqual(s.strip(), SUBSTR.strip())
419 SUBSTR = "aBcDeFG12.'\xa9\x00"
420 sublen = len(SUBSTR)
422 s = SUBSTR * repeats
425 self.assertEqual(s[:sublen * 3], SUBSTR.swapcase() * 3)
426 self.assertEqual(s[-sublen * 3:], SUBSTR.swapcase() * 3)
430 SUBSTR = 'SpaaHAaaAaham'
431 s = SUBSTR * (size // len(SUBSTR) + 2)
433 self.assertTrue(s.startswith((SUBSTR * 3).title()))
434 self.assertTrue(s.endswith(SUBSTR.lower() * 3))
439 SUBSTR = 'aZz.z.Aaz.'
440 sublen = len(SUBSTR)
442 s = SUBSTR * repeats
445 self.assertEqual(s[:sublen], SUBSTR.translate(trans))
446 self.assertEqual(s[-sublen:], SUBSTR.translate(trans))
460 SUBSTR = '-568324723598234'
461 s = SUBSTR.zfill(size)
462 self.assertTrue(s.endswith('0' + SUBSTR[1:]))
465 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)