Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)