How to use the flaky.names.FlakyNames.MAX_RUNS function in flaky

To help you get started, we’ve selected a few flaky 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 box / flaky / test / test_flaky_decorator.py View on Github external
def test_something():
            pass

        flaky_attribute = dict((
            (attr, getattr(
                test_something,
                attr,
                None
            )) for attr in FlakyNames()
        ))

        self.assertIsNotNone(flaky_attribute)
        self.assertDictContainsSubset(
            {
                FlakyNames.MIN_PASSES: min_passes,
                FlakyNames.MAX_RUNS: max_runs,
                FlakyNames.CURRENT_PASSES: 0,
                FlakyNames.CURRENT_RUNS: 0,
                FlakyNames.CURRENT_ERRORS: None
            },
            flaky_attribute
        )
github box / flaky / flaky / _flaky_plugin.py View on Github external
Then rerun the test.

        :param err:
            Information about the test failure (from sys.exc_info())
        :type err:
            `tuple` of `class`, :class:`Exception`, `traceback`
        :param flaky:
            Dictionary of flaky attributes
        :type flaky:
            `dict` of `unicode` to varies
        :param name:
            The test name
        :type name:
            `unicode`
        """
        max_runs = flaky[FlakyNames.MAX_RUNS]
        runs_left = max_runs - flaky[FlakyNames.CURRENT_RUNS]
        message = self._retry_failure_message.format(
            runs_left,
            max_runs,
        )
        self._log_test_failure(name, err, message)
github box / flaky / flaky / defaults.py View on Github external
:return:
        Default flaky attributes to set on a flaky test.
    :rtype:
        `dict`
    """
    if max_runs is None:
        max_runs = 2
    if min_passes is None:
        min_passes = 1
    if min_passes <= 0:
        raise ValueError('min_passes must be positive')
    if max_runs < min_passes:
        raise ValueError('min_passes cannot be greater than max_runs!')

    return {
        FlakyNames.MAX_RUNS: max_runs,
        FlakyNames.MIN_PASSES: min_passes,
        FlakyNames.CURRENT_RUNS: 0,
        FlakyNames.CURRENT_PASSES: 0,
        FlakyNames.RERUN_FILTER: FilterWrapper(rerun_filter or _true),
    }