Beispiel #1
0
 def test_returns_iterator(self):
     stripped = lstrip((1, 2, 3), 1)
     self.assertEqual(iter(stripped), iter(stripped))
Beispiel #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])
Beispiel #3
0
 def test_none_values(self):
     self.assertIterableEqual(lstrip([None, 1, 2, 3], 0), [None, 1, 2, 3])
Beispiel #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])
Beispiel #5
0
 def test_strip_all(self):
     self.assertIterableEqual(lstrip([1, 1, 1], 1), [])
Beispiel #6
0
 def test_empty_iterable(self):
     self.assertIterableEqual(lstrip([], 1), [])
Beispiel #7
0
 def test_string(self):
     self.assertIterableEqual(lstrip('  hello', ' '), 'hello')
Beispiel #8
0
 def test_nothing_to_strip(self):
     self.assertIterableEqual(lstrip([1, 2, 3], 0), [1, 2, 3])
Beispiel #9
0
 def test_list(self):
     self.assertIterableEqual(lstrip([1, 1, 2, 3, 1], 1), [2, 3, 1])