Beispiel #1
0
 def test_empty_keep(self):
     inp = [2, 4, 6, 8, 10]
     out = []
     self.assertEqual(out, keep(inp, lambda x: x % 2 == 1))
Beispiel #2
0
 def test_keep_plus_discard(self):
     inp = ['1,2,3', 'one', 'almost!', 'love']
     out = ['one', 'love', '1,2,3', 'almost!']
     self.assertEqual(out, keep(inp, str.isalpha) + discard(inp, str.isalpha))
Beispiel #3
0
 def test_empty_sequence(self):
     self.assertEqual([], keep([], lambda x: x % 2 == 0))
Beispiel #4
0
 def test_keep_z(self):
     inp = ['zebra', 'arizona', 'apple', 'google', 'mozilla']
     out = ['zebra', 'arizona', 'mozilla']
     self.assertEqual(out, keep(inp, lambda x: 'z' in x))
Beispiel #5
0
 def test_keep_discard(self):
     inp = ['1,2,3', 'one', 'almost!', 'love']
     self.assertEqual([], discard(keep(inp, str.isalpha), str.isalpha))
Beispiel #6
0
 def test_empty_keep(self):
     inp = [2, 4, 6, 8, 10]
     out = []
     self.assertEqual(out, keep(inp, lambda x: x % 2 == 1))
Beispiel #7
0
 def test_keep_everything(self):
     inp = [2, 4, 6, 8, 10]
     self.assertEqual(inp, keep(inp, lambda x: x % 2 == 0))
Beispiel #8
0
 def test_empty_sequence(self):
     self.assertEqual([], keep([], lambda x: x % 2 == 0))
Beispiel #9
0
 def test_keep_plus_discard(self):
     inp = ['1,2,3', 'one', 'almost!', 'love']
     out = ['one', 'love', '1,2,3', 'almost!']
     self.assertEqual(out,
                      keep(inp, str.isalpha) + discard(inp, str.isalpha))
Beispiel #10
0
 def test_keep_discard(self):
     inp = ['1,2,3', 'one', 'almost!', 'love']
     self.assertEqual([], discard(keep(inp, str.isalpha), str.isalpha))
Beispiel #11
0
 def test_keep_z(self):
     inp = ['zebra', 'arizona', 'apple', 'google', 'mozilla']
     out = ['zebra', 'arizona', 'mozilla']
     self.assertEqual(out, keep(inp, lambda x: 'z' in x))
Beispiel #12
0
 def test_keep_everything(self):
     inp = [2, 4, 6, 8, 10]
     self.assertEqual(inp, keep(inp, lambda x: x % 2 == 0))