File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,24 @@ def test_types_hashes(self):
32
32
type_mockup = _create_type_t_mockup (member_type )
33
33
self .assertIsNotNone (hash (type_mockup ))
34
34
35
+ def test_declarations_hashes (self ):
36
+ """
37
+ Test if all the declaration_t instances implement a hash method.
38
+
39
+ The hash is part of the public API, as there are multiple tools
40
+ that rely on it to compare declaration_t instances.
41
+
42
+ The best way to test this is to instanciate dummy declaration_t objects
43
+ for each class that subclasses declaration_t, and check that the hash
44
+ of these objects is not None.
45
+
46
+ """
47
+ members = inspect .getmembers (declarations , inspect .isclass )
48
+ for member in members :
49
+ member_type = member [1 ]
50
+ if issubclass (member_type , declarations .declaration_t ):
51
+ self .assertIsNotNone (hash (member_type ()))
52
+
35
53
36
54
def _create_type_t_mockup (member_type ):
37
55
nbr_parameters = len (inspect .signature (member_type ).parameters )
You can’t perform that action at this time.
0 commit comments