How to use the testslide.lib._validate_callable_arg_types function in TestSlide

To help you get started, we’ve selected a few TestSlide examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebookincubator / TestSlide / tests / lib_testslide.py View on Github external
def assert_passes(self, *args, **kwargs):
        testslide.lib._validate_callable_arg_types(
            self.skip_first_arg, self.callable_template, args, kwargs
        )
github facebookincubator / TestSlide / tests / lib_testslide.py View on Github external
def assert_fails(self, *args, **kwargs):
        with self.assertRaisesRegex(
            testslide.lib.TypeCheckError,
            "Call to "
            + self.callable_template.__name__
            + " has incompatible argument types",
        ):
            testslide.lib._validate_callable_arg_types(
                self.skip_first_arg, self.callable_template, args, kwargs
            )
github facebookincubator / TestSlide / testslide / mock_constructor.py View on Github external
def callable_mock_with_type_validation(*args, **kwargs):
        for callable_template in callable_templates:
            if _validate_callable_signature(
                False,
                callable_template,
                template,
                callable_template.__name__,
                args,
                kwargs,
            ):
                _validate_callable_arg_types(False, callable_template, args, kwargs)
        return callable_mock(*args, **kwargs)
github facebookincubator / TestSlide / tests / lib_testslide.py View on Github external
def gives_correct_error_message_for_invalid_types(self):
        with self.assertRaises(
            testslide.lib.TypeCheckError,
            msg=(
                "Call to test_function has incompatible argument types:\n"
                "  'arg1': type of arg1 must be str; got int instead\n"
                "  'arg2': type of arg2 must be str; got int instead\n"
                "  'kwarg1': type of kwarg1 must be str; got int instead\n"
                "  'kwarg2': type of kwarg2 must be str; got int instead"
            ),
        ):
            testslide.lib._validate_callable_arg_types(
                self.skip_first_arg, self.callable_template, (1, 2, 3, 4), {}
            )