def test_unicode_exception(self): """Exceptions that can be formated losslessly as unicode should be""" example_text, _ = self._get_sample_text() exception_class = ( "class FancyError(Exception):\n" # A __unicode__ method does nothing on py3k but the default works " def __unicode__(self):\n" " return self.args[0]\n") textoutput = self._test_external_case( modulelevel=exception_class, testline="raise FancyError(%s)" % _r(example_text)) self.assertIn(self._as_output(example_text), textoutput)
def test_non_ascii_failure_string_via_exec(self): """Assertion via exec can be non-ascii and still gets decoded""" text, raw = self._get_sample_text(_get_exception_encoding()) textoutput = self._test_external_case( testline='exec ("self.fail(%s)")' % _r(raw)) self.assertIn(self._as_output(text), textoutput)
def test_non_ascii_failure_string(self): """Assertion contents can be non-ascii and should get decoded""" text, raw = self._get_sample_text(_get_exception_encoding()) textoutput = self._test_external_case("self.fail(%s)" % _r(raw)) self.assertIn(self._as_output(text), textoutput)