Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'\n\t',
unicode_type(mock_error.traceback),
'\n',
])
else:
message = ' failed; it passed {0} out of the required {1} times.'
stream.writelines([
self._test_method_name,
message.format(
current_passes,
min_passes
),
'\n\t',
unicode_type(mock_error.type),
'\n\t',
unicode_type(mock_error.value),
'\n\t',
unicode_type(mock_error.traceback),
'\n',
])
assert stream.getvalue() == mock_stream.getvalue()
{
FlakyNames.CURRENT_RUNS: current_runs + 1,
FlakyNames.CURRENT_ERRORS: current_errors
},
test,
)
if expected_plugin_handles_failure:
stream.writelines([
self._test_method_name,
' failed ({} runs remaining out of {}).'.format(
max_runs - current_runs - 1, max_runs
),
'\n\t',
unicode_type(mock_error.type),
'\n\t',
unicode_type(mock_error.value),
'\n\t',
unicode_type(mock_error.traceback),
'\n',
])
else:
message = ' failed; it passed {0} out of the required {1} times.'
stream.writelines([
self._test_method_name,
message.format(
current_passes,
min_passes
),
'\n\t',
unicode_type(mock_error.type),
'\n\t',
unicode_type(mock_error.value),
'\n\t',
unicode_type(mock_error.value),
'\n\t',
unicode_type(mock_error.traceback),
'\n',
])
else:
message = ' failed; it passed {0} out of the required {1} times.'
stream.writelines([
self._test_method_name,
message.format(
current_passes,
min_passes
),
'\n\t',
unicode_type(mock_error.type),
'\n\t',
unicode_type(mock_error.value),
'\n\t',
unicode_type(mock_error.traceback),
'\n',
])
assert stream.getvalue() == mock_stream.getvalue()
def test_ensure_unicode_string_handles_nonascii_exception_message(self):
message = u'\u2013'
encoded_message = message.encode('utf-8')
ex = Exception(encoded_message)
string = ensure_unicode_string(ex)
if sys.version_info >= (3,):
message = unicode_type(encoded_message)
self.assertEqual(string, message)
actual_plugin_handles_failure = flaky_plugin.add_failure(
flaky_test,
mock_error,
)
assert actual_plugin_handles_failure is False
assert not mock_plugin_rerun()
string_io.writelines([
self._test_method_name,
' failed and was not selected for rerun.',
'\n\t',
unicode_type(mock_error.type),
'\n\t',
unicode_type(mock_error.value),
'\n\t',
unicode_type(mock_error.traceback),
'\n',
])
assert string_io.getvalue() == mock_io.getvalue()
'\n',
])
else:
message = ' failed; it passed {0} out of the required {1} times.'
stream.writelines([
self._test_method_name,
message.format(
current_passes,
min_passes
),
'\n\t',
unicode_type(mock_error.type),
'\n\t',
unicode_type(mock_error.value),
'\n\t',
unicode_type(mock_error.traceback),
'\n',
])
assert stream.getvalue() == mock_stream.getvalue()
assert expected_plugin_handles_failure == actual_plugin_handles_failure
self._assert_flaky_attributes_contains(
{
FlakyNames.CURRENT_RUNS: current_runs + 1,
FlakyNames.CURRENT_ERRORS: current_errors
},
test,
)
if expected_plugin_handles_failure:
stream.writelines([
self._test_method_name,
' failed ({} runs remaining out of {}).'.format(
max_runs - current_runs - 1, max_runs
),
'\n\t',
unicode_type(mock_error.type),
'\n\t',
unicode_type(mock_error.value),
'\n\t',
unicode_type(mock_error.traceback),
'\n',
])
else:
message = ' failed; it passed {0} out of the required {1} times.'
stream.writelines([
self._test_method_name,
message.format(
current_passes,
min_passes
),
'\n\t',
unicode_type(mock_error.type),