How to use the flaky.utils.ensure_unicode_string 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_utils.py View on Github external
def test_ensure_unicode_string_handles_various_strings(
            self,
            string,
            expected_unicode_string,
    ):
        unicode_string = ensure_unicode_string(string)
        if sys.version_info >= (3,):
            expected_unicode_string = unicode_type(string)
        self.assertTrue(isinstance(unicode_string, unicode_type))
        self.assertTrue(expected_unicode_string in unicode_string)
github box / flaky / test / test_utils.py View on Github external
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)
github box / flaky / flaky / _flaky_plugin.py View on Github external
def _log_test_failure(self, test_callable_name, err, message):
        """
        Add messaging about a test failure to the stream, which will be
        printed by the plugin's report method.
        """
        formatted_exception_info = ''.join(format_exception(*err)).replace('\n', '\n\t').rstrip()
        self._stream.writelines([
            ensure_unicode_string(test_callable_name),
            ensure_unicode_string(message),
            ensure_unicode_string(formatted_exception_info),
            '\n',
        ])
github box / flaky / flaky / _flaky_plugin.py View on Github external
def _log_test_failure(self, test_callable_name, err, message):
        """
        Add messaging about a test failure to the stream, which will be
        printed by the plugin's report method.
        """
        formatted_exception_info = ''.join(format_exception(*err)).replace('\n', '\n\t').rstrip()
        self._stream.writelines([
            ensure_unicode_string(test_callable_name),
            ensure_unicode_string(message),
            ensure_unicode_string(formatted_exception_info),
            '\n',
        ])
github box / flaky / flaky / _flaky_plugin.py View on Github external
def _log_test_failure(self, test_callable_name, err, message):
        """
        Add messaging about a test failure to the stream, which will be
        printed by the plugin's report method.
        """
        formatted_exception_info = ''.join(format_exception(*err)).replace('\n', '\n\t').rstrip()
        self._stream.writelines([
            ensure_unicode_string(test_callable_name),
            ensure_unicode_string(message),
            ensure_unicode_string(formatted_exception_info),
            '\n',
        ])
github box / flaky / flaky / _flaky_plugin.py View on Github external
name = self._get_test_callable_name(test)
        except AttributeError:
            return False
        need_reruns = self._should_handle_test_success(test)

        if self._has_flaky_attributes(test):
            self._had_flaky_tests = True
            flaky = self._get_flaky_attributes(test)
            min_passes = flaky[FlakyNames.MIN_PASSES]
            passes = flaky[FlakyNames.CURRENT_PASSES] + 1
            self._set_flaky_attribute(test, FlakyNames.CURRENT_PASSES, passes)
            self._increment_flaky_attribute(test, FlakyNames.CURRENT_RUNS)

            if self._flaky_success_report:
                self._stream.writelines([
                    ensure_unicode_string(name),
                    ' passed {} out of the required {} times. '.format(
                        passes,
                        min_passes,
                    ),
                ])
                if need_reruns:
                    self._stream.write(
                        'Running test again until it passes {} times.\n'.format(
                            min_passes,
                        )
                    )
                else:
                    self._stream.write('Success!\n')

        if need_reruns:
            self._mark_test_for_rerun(test)