예제 #1
0
 def test_should_support_indexing(self):
     self.assertEqual(0, Selector(self.iterable)[0])
     self.assertEqual(1, Selector(self.iterable)[1])
     self.assertEqual(2, Selector(self.iterable)[2])
     self.assertEqual(2, Selector(self.iterable)[-1])
예제 #2
0
 def test_should_support_iteration(self):
     self.assertSequenceEqual(self.iterable, list(Selector(self.iterable)))
     self.assertSequenceEqual(self.iterable, Selector(self.iterable).all())
예제 #3
0
 def test_should_return_default_when_index_lower(self):
     self.assertEqual(Default(5), Selector(self.iterable, 5).item(-5))
예제 #4
0
 def test_should_support_index_below_zero(self):
     self.assertEqual(0, Selector(self.iterable).item(-3))
예제 #5
0
 def test_should_return_by_index(self):
     self.assertEqual(1, Selector(self.iterable).item(1))
예제 #6
0
 def test_should_return_last_element(self):
     self.assertEqual(2, Selector(self.iterable).last())
예제 #7
0
 def test_should_return_first_element(self):
     self.assertEqual(0, Selector(self.iterable).first())