示例#1
0
 def test_merge_union_of_same_length_tuples(self):
     # type: () -> None
     assert merge_items([TupleType([CT('str')]),
                         TupleType([CT('int')])]) == [TupleType([UnionType([CT('str'),
                                                                            CT('int')])])]
     assert merge_items([TupleType([CT('str')]),
                         TupleType([CT('Text')])]) == [TupleType([CT('Text')])]
示例#2
0
 def test_cannot_merge(self):
     # type: () -> None
     for first, second in ((CT('str'), CT('Text')),
                           (CT('List', [CT('int')]), CT('List', [CT('str')]))):
         assert merge_items([first, second]) == [first, second]
         assert merge_items([second, first]) == [second, first]
         assert merge_items([first, second, first]) == [first, second, first]
示例#3
0
 def test_merge_tuples_with_different_lengths(self):
     # type: () -> None
     assert merge_items([
         TupleType([CT('str')]),
         TupleType([CT('str'), CT('str')])]) == [CT('Tuple', [CT('str')])]
     assert merge_items([
         TupleType([]),
         TupleType([CT('str')]),
         TupleType([CT('str'), CT('str')])]) == [CT('Tuple', [CT('str')])]
     # Don't merge if types aren't identical
     assert merge_items([
         TupleType([CT('str')]),
         TupleType([CT('str'), CT('int')])]) == [TupleType([CT('str')]),
                                                 TupleType([CT('str'), CT('int')])]
示例#4
0
 def test_merge_union_containing_no_return(self):
     # type: () -> None
     assert merge_items([CT('int'), NoReturnType()]) == [CT('int')]
     assert merge_items([NoReturnType(), CT('int')]) == [CT('int')]