def has_just_params(self, *names): """Are there only parameters of the given names? Example: .. code-block:: python func.has_just_params('p1', 'p2') The order is irrelevant. """ return set(self.param_names) == names_to_set(names)
def has_just_vtables(self, *names): """Are there only vtables of the given names? Example: .. code-block:: python module.has_just_vtables('vt1', 'vt2') The order is irrelevant. """ return set(self.vtable_names) == names_to_set(names)
def has_vtables(self, *names): """Are there vtables of the given names? Example: .. code-block:: python module.has_vtables('vt1', 'vt2') The order is irrelevant. If you want to check that only the given vtable appear in the module and no other vtables, use :func:`has_just_vtables()` instead. If you call this method without any arguments, it checks whether there is at least one vtable in the module: .. code-block:: python module.has_vtables() """ names = names_to_set(names) if not names: return self.vtable_count > 0 return names.issubset(set(self.vtable_names))
def has_params(self, *names): """Are there parameters of the given names? Example: .. code-block:: python func.has_params('p1', 'p2') The order is irrelevant. If you want to check that the function has only the given parameters and no other parameters, use :func:`has_just_params()` instead. If you call this method without any arguments, it checks whether the function has at least one parameter: .. code-block:: python func.has_params() """ names = names_to_set(names) if not names: return self.param_count > 0 return names.issubset(set(self.param_names))
def test_obtains_names_from_nested_list_when_names_contains_another_list(self): self.assertEqual(names_to_set([['a', 'b']]), {'a', 'b'})
def test_turns_names_to_set_when_names_is_list_of_names(self): self.assertEqual(names_to_set(['a', 'b']), {'a', 'b'})
def test_returns_empty_set_when_there_are_no_names(self): self.assertEqual(names_to_set([]), set())