def test_prepare_body(self): r = Request(url=gh_url) r_latin1 = Request(url=gh_url, encoding='latin1') self.assertEqual(r._prepare_body(''), '') body = r._prepare_body(u'Price: \xa3100') self.assertIsInstance(body, str) self.assertEqual(body, 'Price: \xc2\xa3100') latin_body = r_latin1._prepare_body(u'Price: \xa3100') self.assertEqual(latin_body, 'Price: \xa3100') self.assertEqual(r._prepare_body(10), '10')