Exemple #1
0
 def test_compare_dict_in_array(self):
     
     # simple
     self.compare([{'a':1}], [{'a':1}])
     self.compare([{'a':1, 'b':2}], [{'a':1, 'b':2}])
     self.compare([{'a':1}, {'b':2}], [{'a':1}, {'b':2}])
     
     self.compareFalse([{'a':1}], [{'a':1, 'b':2}])
     self.compareFalse([{'a':2, 'b':2}], [{'a':1, 'b':2}])
     self.compareFalse([{'a':2, 'c':3}], [{'a':1, 'b':2}])
     self.compareFalse([{'a':2, 'c':3}], [{'a':1}])
     self.compareFalse([{'a':1}, {'b':2}], [{'a':1, 'b':2}])
     
     # order
     self.compareFalse([{'a':1}, {'b':2}], [{'b':2}, {'a':1}])
     
     # partial
     self.compare(partial([{}]), [{'a':1, 'b':2}])
     self.compare(partial([{}]), [{'a':1, 'b':2}])
     self.compare(partial([{'a':1}]), [{'a':1, 'b':2}])
     self.compare(partial([{'a':1, 'b':2}]), [{'a':1, 'b':2}])
     self.compare(partial([{'a':1}, {'b':2}]), [{'a':1}, {'b':2}, {'c':3}])
     
     self.compareFalse(partial([{'a':2}]), [{'a':1, 'b':2}])
     self.compareFalse(partial([{'a':1, 'b':2}]), [{'a':1}])
     
     # partial order
     self.compareFalse(partial([{'a':1}, {'b':2}], ordered=True), [{'b':2}, {'a':1}])
     
     # partial unordered
     self.compare(partial([{'a':1}, {'b':2}]), [{'b':2}, {'a':1}])
     self.compare(partial([{'a':1}, {'b':2}], ordered=False), [{'b':2}, {'a':1}])
Exemple #2
0
 def test_dict_partial(self):
     
     # simple
     self.compare(partial({'a':1}), {'a':1})
     self.compare(partial({'a':1}), {'a':1, 'b':2})
     
     self.compareFalse(partial({'a':2}), {'a':1, 'b':2})
     self.compareFalse(partial({'c':1}), {'a':1, 'b':2})
     self.compareFalse(partial({'a':1, 'b':2}), {'b':2})
     
     # empty
     self.compare(partial({}), {})
     self.compare(partial({}), {'a':1})
     self.compareFalse(partial({'a':1}), {})
Exemple #3
0
 def test_array_partial(self):
     '''note that these are all in-order'''
     
     # simple
     self.compare(partial([1]), [1,2,3])
     self.compare(partial([2]), [1,2,3])
     self.compare(partial([3]), [1,2,3])
     
     self.compare(partial([1,2]), [1,2,3])
     self.compare(partial([1,3]), [1,2,3])
     
     self.compare(partial([1,2,3]), [1,2,3])
     
     self.compareFalse(partial([4]), [1,2,3])
     
     # ordered
     self.compareFalse(partial([3,2,1], ordered=True), [1,2,3])
     self.compareFalse(partial([1,3,2], ordered=True), [1,2,3])
     
     # empty array
     self.compare(partial([]), [1,2,3])
     
     # multiple of a single items
     self.compare(partial([1,2,2]), [1,2,2,3,3,3])
     self.compareFalse(partial([1,2,2,2]), [1,2,2,3,3,3])
Exemple #4
0
 def test_compare_partial_items_in_array(self):
     self.compare([{'a':1, 'b':1}, partial({'a':2})], [{'a':1, 'b':1}, {'a':2, 'b':2}])
Exemple #5
0
    def test_array_partial(self):
        '''note that these are all in-order'''

        # simple
        self.compare(partial([1]), [1, 2, 3])
        self.compare(partial([2]), [1, 2, 3])
        self.compare(partial([3]), [1, 2, 3])

        self.compare(partial([1, 2]), [1, 2, 3])
        self.compare(partial([1, 3]), [1, 2, 3])

        self.compare(partial([1, 2, 3]), [1, 2, 3])

        self.compareFalse(partial([4]), [1, 2, 3])

        # ordered
        self.compareFalse(partial([3, 2, 1], ordered=True), [1, 2, 3])
        self.compareFalse(partial([1, 3, 2], ordered=True), [1, 2, 3])

        # empty array
        self.compare(partial([]), [1, 2, 3])

        # multiple of a single items
        self.compare(partial([1, 2, 2]), [1, 2, 2, 3, 3, 3])
        self.compareFalse(partial([1, 2, 2, 2]), [1, 2, 2, 3, 3, 3])