示例#1
0
    def test_invalid_input(self):
        source = ['x', 1, 'y', 2]
        with self.assertRaises(TypeError):
            normalized = _get_iteritems(source)

        source = [{'x': 1}, {'y': 2}]
        with self.assertRaises(TypeError):
            normalized = _get_iteritems(source)
示例#2
0
 def test_list_of_items(self):
     items = _get_iteritems([('a', 1), ('b', 2)])
     self.assertEqual(list(items), [('a', 1), ('b', 2)])
示例#3
0
 def test_get_iteritems(self):
     items_iter = _get_iteritems([('a', 1), ('b', 2)])
     self.assertTrue(_is_collection_of_items(items_iter))
示例#4
0
 def test_Query(self):
     source = Select([('A', 'B'), ('x', 1), ('y', 2)])
     query = source({'A': 'B'}).apply(lambda x: next(x))
     normalized = _get_iteritems(query)
     self.assertEqual(list(normalized), [('x', 1), ('y', 2)])
示例#5
0
 def test_Result(self):
     result = Result(_get_iteritems([('a', 1), ('b', 2)]), evaltype=dict)
     normalized = _get_iteritems(result)
     self.assertEqual(list(normalized), [('a', 1), ('b', 2)])
示例#6
0
 def test_empty_iterable(self):
     items = _get_iteritems(iter([]))
     self.assertEqual(list(items), [])
示例#7
0
 def test_dict(self):
     items = _get_iteritems({'a': 1, 'b': 2})
     self.assertEqual(set(items), set([('a', 1), ('b', 2)]))