Ejemplo n.º 1
0
    def generate_cluster(self) -> TestCluster:
        """Generate new test cluster from the configured modules.

        Returns:
            The new test cluster
        """
        self._logger.debug("Generating test cluster")
        self._logger.debug("Analyzing module %s", self._module_name)
        module = importlib.import_module(self._module_name)
        for _, klass in inspect.getmembers(module, class_in_module(self._module_name)):
            self._add_dependency(klass, 1, True)

        for function_name, funktion in inspect.getmembers(
            module, function_in_module(self._module_name)
        ):

            generic_function = GenericFunction(
                funktion, self._inference.infer_type_info(funktion)[0]
            )
            if self._is_protected(
                function_name
            ) or self._discard_accessible_with_missing_type_hints(generic_function):
                self._logger.debug("Skip function %s", function_name)
                continue

            self._logger.debug("Analyzing function %s", function_name)
            self._test_cluster.add_generator(generic_function)
            self._test_cluster.add_accessible_object_under_test(generic_function)
            self._add_callable_dependencies(generic_function, 1)
        self._resolve_dependencies_recursive()
        return self._test_cluster
Ejemplo n.º 2
0
def function_mock() -> GenericFunction:
    return GenericFunction(
        function=simple_function,
        inferred_signature=InferredSignature(
            signature=inspect.Signature(parameters=[
                inspect.Parameter(
                    name="z",
                    kind=inspect.Parameter.POSITIONAL_OR_KEYWORD,
                    annotation=float,
                ),
            ]),
            return_type=float,
            parameters={"z": float},
        ),
    )
Ejemplo n.º 3
0
def test_generic_function_eq_modified(function_mock):
    second = GenericFunction(int, MagicMock(InferredSignature))
    assert function_mock != second