From c03ccaff1eb05ca68ce140b7a279aa3bcdb2db71 Mon Sep 17 00:00:00 2001 From: Dev doomari Date: Mon, 7 Dec 2020 17:08:50 +0900 Subject: [PATCH] add __name__ == '__main__' on all test files --- .../test_class_with_generic_instance_and_inheritance.py | 6 ++++++ .../type_extractor/__tests__/test_class_with_method.py | 7 ++++++- .../__tests__/test_classes_with_inheritance.py | 4 ++++ .../type_extractor/__tests__/test_enum_class.py | 4 ++++ .../type_extractor/__tests__/test_func_not_annotated.py | 6 +++++- .../type_extractor/__tests__/test_func_with_arg_class.py | 4 ++++ .../__tests__/test_func_with_builtin_type_args.py | 6 +++++- .../type_extractor/__tests__/test_func_with_dict.py | 6 +++++- .../type_extractor/__tests__/test_func_with_literals.py | 6 +++++- .../type_extractor/__tests__/test_func_with_mapping.py | 7 ++++++- .../__tests__/test_func_with_nested_arg_class.py | 8 +++++++- .../type_extractor/__tests__/test_func_with_tuple.py | 7 ++++++- .../type_extractor/__tests__/test_func_with_typed_dict.py | 6 +++++- .../type_extractor/__tests__/test_newtype.py | 4 ++++ .../type_extractor/__tests__/test_pydantic_classes.py | 6 +++++- .../type_extractor/__tests__/test_various_classes.py | 4 ++++ 16 files changed, 81 insertions(+), 10 deletions(-) diff --git a/py_type_extractor/type_extractor/__tests__/test_class_with_generic_instance_and_inheritance.py b/py_type_extractor/type_extractor/__tests__/test_class_with_generic_instance_and_inheritance.py index d166051..3e4d4af 100644 --- a/py_type_extractor/type_extractor/__tests__/test_class_with_generic_instance_and_inheritance.py +++ b/py_type_extractor/type_extractor/__tests__/test_class_with_generic_instance_and_inheritance.py @@ -1,5 +1,6 @@ import py_type_extractor.test_fixtures.generic_classes as t2 import py_type_extractor.test_fixtures.generic_classes_extended as t +from py_type_extractor.type_extractor.__tests__.utils import hash_test from py_type_extractor.type_extractor.__tests__.utils.cleanup_node import cleanup from py_type_extractor.type_extractor.__tests__.utils.traverse_node import traverse from py_type_extractor.type_extractor.nodes.ClassFound import ClassFound @@ -152,3 +153,8 @@ def test_class_with_generic_instance_and_inheritance(): type_vars=[float, str] ) ] + + hash_test(type_extractor) + +if __name__ == '__main__': + test_class_with_generic_instance_and_inheritance() diff --git a/py_type_extractor/type_extractor/__tests__/test_class_with_method.py b/py_type_extractor/type_extractor/__tests__/test_class_with_method.py index dd28fd4..b6b9846 100644 --- a/py_type_extractor/type_extractor/__tests__/test_class_with_method.py +++ b/py_type_extractor/type_extractor/__tests__/test_class_with_method.py @@ -11,6 +11,7 @@ module_name = t.__name__ + def test_class_with_method(): type_extractor = TypeExtractor() type_extractor.add()(t.ClassWithMethod) @@ -54,4 +55,8 @@ def test_class_with_method(): assert classes[class_type_key] == class_with_method print(type_extractor) - hash_test(type_extractor) \ No newline at end of file + hash_test(type_extractor) + + +if __name__ == '__main__': + test_class_with_method() \ No newline at end of file diff --git a/py_type_extractor/type_extractor/__tests__/test_classes_with_inheritance.py b/py_type_extractor/type_extractor/__tests__/test_classes_with_inheritance.py index aeee341..4075088 100644 --- a/py_type_extractor/type_extractor/__tests__/test_classes_with_inheritance.py +++ b/py_type_extractor/type_extractor/__tests__/test_classes_with_inheritance.py @@ -62,3 +62,7 @@ def test_classes_with_inheritance(): ], ) hash_test(type_extractor) + + +if __name__ == '__main__': + test_classes_with_inheritance() diff --git a/py_type_extractor/type_extractor/__tests__/test_enum_class.py b/py_type_extractor/type_extractor/__tests__/test_enum_class.py index a9303cf..fb70636 100644 --- a/py_type_extractor/type_extractor/__tests__/test_enum_class.py +++ b/py_type_extractor/type_extractor/__tests__/test_enum_class.py @@ -30,3 +30,7 @@ def test_enum_class(): name=t.SomeEnumClass.__qualname__, ) hash_test(type_extractor) + + +if __name__ == '__main__': + test_enum_class() diff --git a/py_type_extractor/type_extractor/__tests__/test_func_not_annotated.py b/py_type_extractor/type_extractor/__tests__/test_func_not_annotated.py index 047b574..ffecbe1 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_not_annotated.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_not_annotated.py @@ -32,4 +32,8 @@ def test_func_not_annotated(): cleanup, ) - hash_test(type_collector) \ No newline at end of file + hash_test(type_collector) + + +if __name__ == '__main__': + test_func_not_annotated() \ No newline at end of file diff --git a/py_type_extractor/type_extractor/__tests__/test_func_with_arg_class.py b/py_type_extractor/type_extractor/__tests__/test_func_with_arg_class.py index 577243a..101a0d7 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_with_arg_class.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_with_arg_class.py @@ -41,3 +41,7 @@ def test_func_with_arg_class(): ) hash_test(type_collector) + + +if __name__ == '__main__': + test_func_with_arg_class() \ No newline at end of file diff --git a/py_type_extractor/type_extractor/__tests__/test_func_with_builtin_type_args.py b/py_type_extractor/type_extractor/__tests__/test_func_with_builtin_type_args.py index ed4a761..9dd665e 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_with_builtin_type_args.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_with_builtin_type_args.py @@ -38,4 +38,8 @@ def test_func_with_builtin_type_args(): }, )) - hash_test(type_collector) \ No newline at end of file + hash_test(type_collector) + + +if __name__ == '__main__': + test_func_with_builtin_type_args() \ No newline at end of file diff --git a/py_type_extractor/type_extractor/__tests__/test_func_with_dict.py b/py_type_extractor/type_extractor/__tests__/test_func_with_dict.py index ea2954d..d2d9c13 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_with_dict.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_with_dict.py @@ -35,4 +35,8 @@ def test_func_with_dict(): cleanup, ) - hash_test(type_collector) \ No newline at end of file + hash_test(type_collector) + + +if __name__ == '__main__': + test_func_with_dict() \ No newline at end of file diff --git a/py_type_extractor/type_extractor/__tests__/test_func_with_literals.py b/py_type_extractor/type_extractor/__tests__/test_func_with_literals.py index 885323c..514ff2d 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_with_literals.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_with_literals.py @@ -41,4 +41,8 @@ def test_func_with_literals(): ) assert func_found_cleaned == expected_func_found_cleaned - hash_test(type_collector) \ No newline at end of file + hash_test(type_collector) + + +if __name__ == '__main__': + test_func_with_literals() \ No newline at end of file diff --git a/py_type_extractor/type_extractor/__tests__/test_func_with_mapping.py b/py_type_extractor/type_extractor/__tests__/test_func_with_mapping.py index bf99ce9..2e61876 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_with_mapping.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_with_mapping.py @@ -6,7 +6,8 @@ module_name = t.__name__ -def test_func_with_tuple(): + +def test_func_with_mapping(): type_collector = TypeExtractor() type_collector.add(None)(t.func_with_mapping) @@ -32,3 +33,7 @@ def test_func_with_tuple(): ) hash_test(type_collector) + + +if __name__ == '__main__': + test_func_with_mapping() diff --git a/py_type_extractor/type_extractor/__tests__/test_func_with_nested_arg_class.py b/py_type_extractor/type_extractor/__tests__/test_func_with_nested_arg_class.py index 3ab5897..b07a9a9 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_with_nested_arg_class.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_with_nested_arg_class.py @@ -5,6 +5,8 @@ from py_type_extractor.type_extractor.type_extractor import TypeExtractor module_name = __name__ + + def test_func_with_nested_arg_class(): type_collector = TypeExtractor() @@ -56,4 +58,8 @@ def to_collected_types_key(a): parent_cleaned = traverse(parent_class, cleanup) assert (parent_cleaned == cleanedup) - hash_test(type_collector) \ No newline at end of file + hash_test(type_collector) + + +if __name__ == '__main__': + test_func_with_nested_arg_class() diff --git a/py_type_extractor/type_extractor/__tests__/test_func_with_tuple.py b/py_type_extractor/type_extractor/__tests__/test_func_with_tuple.py index 5471688..e89d2a4 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_with_tuple.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_with_tuple.py @@ -7,6 +7,7 @@ module_name = t.__name__ + def test_func_with_tuple(): type_collector = TypeExtractor() @@ -33,4 +34,8 @@ def test_func_with_tuple(): cleanup, ) - hash_test(type_collector) \ No newline at end of file + hash_test(type_collector) + + +if __name__ == '__main__': + test_func_with_tuple() diff --git a/py_type_extractor/type_extractor/__tests__/test_func_with_typed_dict.py b/py_type_extractor/type_extractor/__tests__/test_func_with_typed_dict.py index 9c2b041..f7f5497 100644 --- a/py_type_extractor/type_extractor/__tests__/test_func_with_typed_dict.py +++ b/py_type_extractor/type_extractor/__tests__/test_func_with_typed_dict.py @@ -58,4 +58,8 @@ def test_func_with_typed_dict(): ) assert cleaned_func == to_compare_func - hash_test(type_collector) \ No newline at end of file + hash_test(type_collector) + + +if __name__ == '__main__': + test_func_with_typed_dict() diff --git a/py_type_extractor/type_extractor/__tests__/test_newtype.py b/py_type_extractor/type_extractor/__tests__/test_newtype.py index dea3eda..6c472a4 100644 --- a/py_type_extractor/type_extractor/__tests__/test_newtype.py +++ b/py_type_extractor/type_extractor/__tests__/test_newtype.py @@ -59,3 +59,7 @@ def test_newtype(): ) hash_test(type_extractor) + + +if __name__ == '__main__': + test_newtype() diff --git a/py_type_extractor/type_extractor/__tests__/test_pydantic_classes.py b/py_type_extractor/type_extractor/__tests__/test_pydantic_classes.py index f586735..ae16c66 100644 --- a/py_type_extractor/type_extractor/__tests__/test_pydantic_classes.py +++ b/py_type_extractor/type_extractor/__tests__/test_pydantic_classes.py @@ -57,4 +57,8 @@ def test_pydantic_classes(): ] ) - hash_test(type_extractor) \ No newline at end of file + hash_test(type_extractor) + + +if __name__ == '__main__': + test_pydantic_classes() diff --git a/py_type_extractor/type_extractor/__tests__/test_various_classes.py b/py_type_extractor/type_extractor/__tests__/test_various_classes.py index c748ab1..05f8400 100644 --- a/py_type_extractor/type_extractor/__tests__/test_various_classes.py +++ b/py_type_extractor/type_extractor/__tests__/test_various_classes.py @@ -64,3 +64,7 @@ def test_various_classes(): assert (functions_list.__len__() == 0) hash_test(type_extractor) + + +if __name__ == '__main__': + test_various_classes()