示例#1
0
 def test_it_renders_via_the_given_encoding(self):
     renderer = renderers.Unicode(encoding="utf-8")
     render = renderers.bind(renderer, to=lambda _: u"שלום")
     self.assertEqual(
         render(self.request),
         Response(u"שלום".encode("utf-8")),
     )
示例#2
0
 def test_encoding_errors_by_default(self):
     renderer = renderers.Unicode(encoding="ascii")
     render = renderers.bind(renderer, to=lambda _: u"שלום")
     with self.assertRaises(UnicodeEncodeError):
         render(self.request)
示例#3
0
 def test_encoding_ignoring_errors(self):
     renderer = renderers.Unicode(encoding="ascii", errors="ignore")
     render = renderers.bind(renderer, to=lambda _: u"שלום")
     self.assertEqual(render(self.request), Response(b""))