def test_any_tuple_constant(self): input = (1, '2', False) node = ast.parse(str(input)).body[0].value expected_output = TupleType(UnionType.build([Type.str, Type.int])) typeanalyser = TypeAnalyser(Analyser(node), {}) output = typeanalyser.get_type(input) self.assertEqual(expected_output, output)
def test_integer_list_constant(self): input = [1, 2, 3] node = ast.parse(str(input)).body[0].value expected_output = ListType(Type.int) typeanalyser = TypeAnalyser(Analyser(node), {}) output = typeanalyser.get_type(input) self.assertEqual(expected_output, output)
def test_string_tuple_constant(self): input = (1, 2, 3) node = ast.parse(str(input)).body[0].value expected_output = TupleType(Type.int) typeanalyser = TypeAnalyser(Analyser(node), {}) output = typeanalyser.get_type(input) self.assertEqual(expected_output, output)
def test_boolean_tuple_constant(self): input = (True, False) node = ast.parse(str(input)).body[0].value expected_output = TupleType(Type.bool) typeanalyser = TypeAnalyser(Analyser(node), {}) output = typeanalyser.get_type(input) self.assertEqual(expected_output, output)
def test_string_constant(self): input = 'unit_test' node = ast.parse(str(input)).body[0].value expected_output = Type.str typeanalyser = TypeAnalyser(Analyser(node), {}) output = typeanalyser.get_type(input) self.assertEqual(expected_output, output)
def test_negative_integer_constant(self): input = -10 node = ast.parse(str(input)).body[0].value expected_output = Type.int typeanalyser = TypeAnalyser(Analyser(node), {}) output = typeanalyser.get_type(input) self.assertEqual(expected_output, output)
def test_any_list_constant(self): input = [1, '2', False] node = ast.parse(str(input)).body[0].value expected_output = ListType(Type.any) typeanalyser = TypeAnalyser(Analyser(node), {}) output = typeanalyser.get_type(input) self.assertEqual(expected_output, output)