def test_select_many_with_index_infinite(self):
     a = infinite()
     b = Queryable(a).select_many_with_index(
         lambda index, source_element: [source_element] * index).take(
             10).to_list()
     c = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]
     self.assertEqual(b, c)
Пример #2
0
    def test_group_join_infinite(self):
        a = infinite()
        b = [2, 3, 5]
        c = Queryable(a).group_join(b).take(3).to_list()

        self.assertEqual(c[0].key, 0)
        self.assertEqual(len(c[0]), 0)

        self.assertEqual(c[1].key, 1)
        self.assertEqual(len(c[1]), 0)

        self.assertEqual(c[2].key, 2)
        self.assertEqual(len(c[2]), 1)
        self.assertTrue(2 in c[2])
Пример #3
0
    def test_group_join_infinite(self):
        a = infinite()
        b = [2, 3, 5]
        c = Queryable(a).group_join(b).take(3).to_list()

        self.assertEqual(c[0].key, 0)
        self.assertEqual(len(c[0]), 0)

        self.assertEqual(c[1].key, 1)
        self.assertEqual(len(c[1]), 0)

        self.assertEqual(c[2].key, 2)
        self.assertEqual(len(c[2]), 1)
        self.assertTrue(2 in c[2])
Пример #4
0
 def test_element_at_infinite(self):
     b = Queryable(infinite()).element_at(5)
     self.assertEqual(b, 5)
Пример #5
0
 def test_join_infinite(self):
     a = infinite()
     b = [2, 3, 4, 5, 6]
     c = Queryable(a).join(b).take(3).to_list()
     d = [(2, 2), (3, 3), (4, 4)]
     self.assertEqual(c, d)
Пример #6
0
 def test_take_from_infinite(self):
     b = Queryable(infinite()).take(5).to_list()
     c = [0, 1, 2, 3, 4]
     self.assertEqual(b, c)
Пример #7
0
 def test_getitem_infinite(self):
     b = Queryable(infinite())[5]
     self.assertEqual(b, 5)
Пример #8
0
 def test_eq_infinite_finite(self):
     a = (1, 2, 3, 5, 16, 32)
     b = infinite()
     c = Queryable(a) == b
     self.assertFalse(c)
Пример #9
0
 def test_join_infinite(self):
     a = infinite()
     b = [2, 3, 4, 5, 6]
     c = Queryable(a).join(b).take(3).to_list()
     d = [(2, 2), (3, 3), (4, 4)]
     self.assertEqual(c, d)
Пример #10
0
 def test_default_if_empty_infinite(self):
     b = Queryable(infinite()).default_if_empty(42).take(5).to_list()
     self.assertEqual(b, [0, 1, 2, 3, 4])
Пример #11
0
 def test_intersect_infinite(self):
     b = [3, 7, 2, 9, 10]
     c = Queryable(infinite()).intersect(b).take(5).to_list()
     d = [2, 3, 7, 9, 10]
     self.assertEqual(c, d)
Пример #12
0
 def test_zip_infinite(self):
     c = Queryable(infinite()).zip(infinite()).take(4).to_list()
     self.assertEqual(c, [(0, 0), (1, 1), (2, 2), (3, 3)])
Пример #13
0
 def test_difference_infinite(self):
     b = [3, 7, 2, 9, 10]
     c = Queryable(infinite()).difference(b).take(10).to_list()
     d = [0, 1, 4, 5, 6, 8, 11, 12, 13, 14]
     self.assertEqual(c, d)
Пример #14
0
 def test_reversed_non_sequence(self):
     a = infinite()
     b = list(reversed(Queryable(a).take(10)))
     c = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
     self.assertEqual(b, c)
Пример #15
0
 def test_select_infinite(self):
     a = infinite()
     b = Queryable(a).select(lambda x: x*2).take(3).to_list()
     c = [0, 2, 4]
     self.assertEqual(b, c)
Пример #16
0
 def test_where_infinite(self):
     a = infinite()
     b = Queryable(a).where(lambda x: x % 5 == 0).take(3).to_list()
     c = [0, 5, 10]
     self.assertEqual(b, c)
Пример #17
0
 def test_sequence_equal_infinite_finite(self):
     a = (1, 2, 3, 5, 16, 32)
     b = infinite()
     c = Queryable(a).sequence_equal(b)
     self.assertFalse(c)
Пример #18
0
 def test_first_predicate_infinite(self):
     a = infinite()
     b = Queryable(a).first(lambda x: x >= 50)
     self.assertEqual(b, 50)
Пример #19
0
 def test_concat_infinite(self):
     b = Queryable(infinite()).concat(infinite()).take(3).to_list()
     c = [0, 1, 2]
     self.assertEqual(b, c)
Пример #20
0
 def test_difference_infinite(self):
     b = [3, 7, 2, 9, 10]
     c = Queryable(infinite()).difference(b).take(10).to_list()
     d = [0, 1, 4, 5, 6, 8, 11, 12, 13, 14]
     self.assertEqual(c, d)
Пример #21
0
 def test_getitem_infinite(self):
     b = Queryable(infinite())[5]
     self.assertEqual(b, 5)
Пример #22
0
 def test_distinct_infinite(self):
     b = Queryable(infinite()).distinct().take(5).to_list()
     c = [0, 1, 2, 3, 4]
     self.assertEqual(b, c)
Пример #23
0
 def test_select_many_infinite(self):
     a = infinite()
     b = Queryable(a).select_many(lambda x: [x] * x).take(10).to_list()
     c = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]
     self.assertEqual(b, c)
Пример #24
0
 def test_ne_infinite_finite(self):
     a = (1, 2, 3, 5, 16, 32)
     b = infinite()
     c = Queryable(a) != b
     self.assertTrue(c)
Пример #25
0
 def test_skip_from_infinite(self):
     b = Queryable(infinite()).skip(5).take(3).to_list()
     c = [5, 6, 7]
     self.assertEqual(b, c)
Пример #26
0
 def test_eq_infinite_finite(self):
     a = (1, 2, 3, 5, 16, 32)
     b = infinite()
     c = Queryable(a) == b
     self.assertFalse(c)
Пример #27
0
 def test_any_infinite(self):
     b = Queryable(infinite()).any()
     self.assertTrue(b)
Пример #28
0
 def test_where_infinite(self):
     a = infinite()
     b = Queryable(a).where(lambda x: x % 5 == 0).take(3).to_list()
     c = [0, 5, 10]
     self.assertEqual(b, c)
Пример #29
0
 def test_zip_infinite(self):
     c = Queryable(infinite()).zip(infinite()).take(4).to_list()
     self.assertEqual(c, [(0, 0), (1, 1), (2, 2), (3, 3)])
Пример #30
0
 def test_select_with_index_infinite(self):
     a = infinite()
     b = Queryable(a).select_with_index(lambda x, y: x * y).take(
         4).to_list()
     c = [0, 1, 4, 9]
     self.assertEqual(b, c)
Пример #31
0
 def test_element_at_out_of_range_infinite(self):
     self.assertRaises(ValueError, lambda: Queryable(infinite()).element_at(-1))
Пример #32
0
 def test_union_infinite(self):
     b = [3, 7, 2, 9, 10]
     c = Queryable(infinite()).union(b).take(5).to_list()
     d = [0, 1, 2, 3, 4]
     self.assertEqual(c, d)
Пример #33
0
 def test_first_infinite(self):
     b = Queryable(infinite()).first()
     self.assertEqual(b, 0)
Пример #34
0
 def test_select_infinite(self):
     a = infinite()
     b = Queryable(a).select(lambda x: x * 2).take(3).to_list()
     c = [0, 2, 4]
     self.assertEqual(b, c)
Пример #35
0
 def test_intersect_infinite(self):
     b = [3, 7, 2, 9, 10]
     c = Queryable(infinite()).intersect(b).take(5).to_list()
     d = [2, 3, 7, 9, 10]
     self.assertEqual(c, d)
Пример #36
0
 def test_reversed_non_sequence(self):
     a = infinite()
     b = list(reversed(Queryable(a).take(10)))
     c = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
     self.assertEqual(b, c)
Пример #37
0
 def test_concat_infinite(self):
     b = Queryable(infinite()).concat(infinite()).take(3).to_list()
     c = [0, 1, 2]
     self.assertEqual(b, c)
Пример #38
0
 def test_distinct_infinite(self):
     b = Queryable(infinite()).distinct().take(5).to_list()
     c = [0, 1, 2, 3, 4]
     self.assertEqual(b, c)
Пример #39
0
 def test_getitem_out_of_range_infinite(self):
     self.assertRaises(IndexError, lambda: Queryable(infinite())[-1])
Пример #40
0
 def test_first_infinite(self):
     b = Queryable(infinite()).first()
     self.assertEqual(b, 0)
Пример #41
0
 def test_first_or_default_infinite(self):
     b = Queryable(infinite()).first_or_default(37)
     self.assertEqual(b, 0)
Пример #42
0
 def test_reverse_non_sequence(self):
     a = infinite()
     b = Queryable(a).take(10).reverse().to_list()
     c = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
     self.assertEqual(b, c)
Пример #43
0
 def test_select_with_index_infinite(self):
     a = infinite()
     b = Queryable(a).select_with_index(lambda x, y: x*y).take(4).to_list()
     c = [0, 1, 4, 9]
     self.assertEqual(b, c)
Пример #44
0
 def test_element_at_infinite(self):
     b = Queryable(infinite()).element_at(5)
     self.assertEqual(b, 5)
Пример #45
0
 def test_first_predicate_infinite(self):
     a = infinite()
     b = Queryable(a).first(lambda x: x >= 50)
     self.assertEqual(b, 50)
Пример #46
0
 def test_ne_infinite_finite(self):
     a = (1, 2, 3, 5, 16, 32)
     b = infinite()
     c = Queryable(a) != b
     self.assertTrue(c)
Пример #47
0
 def test_element_at_out_of_range_infinite(self):
     self.assertRaises(ValueError,
                       lambda: Queryable(infinite()).element_at(-1))
Пример #48
0
 def test_default_if_empty_infinite(self):
     b = Queryable(infinite()).default_if_empty(42).take(5).to_list()
     self.assertEqual(b, [0, 1, 2, 3, 4])
Пример #49
0
 def test_contains_infinite(self):
     a = infinite()
     b = Queryable(a).contains(37)
     self.assertTrue(b)
Пример #50
0
 def test_sequence_equal_infinite_finite(self):
     a = (1, 2, 3, 5, 16, 32)
     b = infinite()
     c = Queryable(a).sequence_equal(b)
     self.assertFalse(c)
Пример #51
0
 def test_getitem_out_of_range_infinite(self):
     self.assertRaises(IndexError, lambda: Queryable(infinite())[-1])
Пример #52
0
 def test_select_with_args_infinite(self):
     a = infinite()
     b = Queryable(a).select_with_args(lambda x: x * 2).take(4).to_list()
     c = [(x, x * 2) for x in range(4)]
     self.assertListEqual(b, c)
Пример #53
0
 def test_contains_infinite(self):
     a = infinite()
     b = Queryable(a).contains(37)
     self.assertTrue(b)
Пример #54
0
 def test_take_while_from_infinite(self):
     b = Queryable(infinite()).take_while(lambda x: x < 5).to_list()
     c = [0, 1, 2, 3, 4]
     self.assertEqual(b, c)
Пример #55
0
 def test_any_infinite_predicate(self):
     b = Queryable(infinite()).any(lambda x: x == 1000)
Пример #56
0
 def test_any_infinite(self):
     b = Queryable(infinite()).any()
     self.assertTrue(b)
Пример #57
0
 def test_any_infinite_predicate(self):
     b = Queryable(infinite()).any(lambda x: x == 1000)
 def test_select_many_with_index_infinite(self):
     a = infinite()
     b = Queryable(a).select_many_with_index(lambda index, source_element: [source_element] * index).take(10).to_list()
     c = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]
     self.assertEqual(b, c)