Пример #1
0
 def test_returns_iterator(self):
     stripped = lstrip((1, 2, 3), 1)
     self.assertEqual(iter(stripped), iter(stripped))
Пример #2
0
 def test_function_given(self):
     numbers = [0, 2, 4, 1, 3, 5, 6]
     def is_even(n): return n % 2 == 0
     self.assertIterableEqual(lstrip(numbers, is_even), [1, 3, 5, 6])
Пример #3
0
 def test_none_values(self):
     self.assertIterableEqual(lstrip([None, 1, 2, 3], 0), [None, 1, 2, 3])
Пример #4
0
 def test_iterator(self):
     squares = (n**2 for n in [0, 0, 1, 2, 3])
     self.assertIterableEqual(lstrip(squares, 0), [1, 4, 9])
Пример #5
0
 def test_strip_all(self):
     self.assertIterableEqual(lstrip([1, 1, 1], 1), [])
Пример #6
0
 def test_empty_iterable(self):
     self.assertIterableEqual(lstrip([], 1), [])
Пример #7
0
 def test_string(self):
     self.assertIterableEqual(lstrip('  hello', ' '), 'hello')
Пример #8
0
 def test_nothing_to_strip(self):
     self.assertIterableEqual(lstrip([1, 2, 3], 0), [1, 2, 3])
Пример #9
0
 def test_list(self):
     self.assertIterableEqual(lstrip([1, 1, 2, 3, 1], 1), [2, 3, 1])