(cls)
| 864 | f = F() |
| 865 | |
| 866 | def validate_class(cls): |
| 867 | # First, check __annotations__, even though they're not |
| 868 | # function annotations. |
| 869 | self.assertEqual(cls.__annotations__['i'], int) |
| 870 | self.assertEqual(cls.__annotations__['j'], str) |
| 871 | self.assertEqual(cls.__annotations__['k'], F) |
| 872 | self.assertEqual(cls.__annotations__['l'], float) |
| 873 | self.assertEqual(cls.__annotations__['z'], complex) |
| 874 | |
| 875 | # Verify __init__. |
| 876 | |
| 877 | signature = inspect.signature(cls.__init__) |
| 878 | # Check the return type, should be None. |
| 879 | self.assertIs(signature.return_annotation, None) |
| 880 | |
| 881 | # Check each parameter. |
| 882 | params = iter(signature.parameters.values()) |
| 883 | param = next(params) |
| 884 | # This is testing an internal name, and probably shouldn't be tested. |
| 885 | self.assertEqual(param.name, 'self') |
| 886 | param = next(params) |
| 887 | self.assertEqual(param.name, 'i') |
| 888 | self.assertIs (param.annotation, int) |
| 889 | self.assertEqual(param.default, inspect.Parameter.empty) |
| 890 | self.assertEqual(param.kind, inspect.Parameter.POSITIONAL_OR_KEYWORD) |
| 891 | param = next(params) |
| 892 | self.assertEqual(param.name, 'j') |
| 893 | self.assertIs (param.annotation, str) |
| 894 | self.assertEqual(param.default, inspect.Parameter.empty) |
| 895 | self.assertEqual(param.kind, inspect.Parameter.POSITIONAL_OR_KEYWORD) |
| 896 | param = next(params) |
| 897 | self.assertEqual(param.name, 'k') |
| 898 | self.assertIs (param.annotation, F) |
| 899 | # Don't test for the default, since it's set to MISSING. |
| 900 | self.assertEqual(param.kind, inspect.Parameter.POSITIONAL_OR_KEYWORD) |
| 901 | param = next(params) |
| 902 | self.assertEqual(param.name, 'l') |
| 903 | self.assertIs (param.annotation, float) |
| 904 | # Don't test for the default, since it's set to MISSING. |
| 905 | self.assertEqual(param.kind, inspect.Parameter.POSITIONAL_OR_KEYWORD) |
| 906 | self.assertRaises(StopIteration, next, params) |
| 907 | |
| 908 | |
| 909 | @dataclass |
nothing calls this directly
no test coverage detected