Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_flaky_plugin_handles_bare_test(self):
self._mock_test_names = self._mock_test_method_name
self._mock_test.test = Mock()
self._expect_call_test_address()
attrib = defaults.default_flaky_attributes(2, 1)
for name, value in attrib.items():
setattr(
self._mock_test.test,
name,
value,
)
delattr(self._mock_test, self._mock_test_method_name)
self._flaky_plugin.prepareTestCase(self._mock_test_case)
self.assertTrue(self._flaky_plugin.handleError(
self._mock_test_case,
self._mock_error,
))
self.assertFalse(self._flaky_plugin.handleError(
self._mock_test_case,
self._mock_error,
))
Filter function to decide whether a test should be rerun if it fails.
Function signature is as follows:
(err, name, test, plugin) -> should_rerun
- err (`tuple` of `class`, :class:`Exception`, `traceback`):
Information about the test failure (from sys.exc_info())
- name (`unicode`):
The test name
- test (:class:`nose.case.Test` or :class:`Function`):
The test that has raised an error
- plugin (:class:`FlakyNosePlugin` or :class:`FlakyPytestPlugin`):
The flaky plugin. Has a :prop:`stream` that can be written to in
order to add to the Flaky Report.
:type rerun_filter:
`callable`
"""
attrib_dict = defaults.default_flaky_attributes(max_runs, min_passes, rerun_filter)
for attr, value in attrib_dict.items():
cls._set_flaky_attribute(test, attr, value)