Scrapy, a fast high-level web crawling & scraping framework for Python.
TST fix to_bytes and to_unicode tests in Python 3.x
Mikhail Korobov41bcae5d00a3
diff --git a/tests/test_utils_python.py b/tests/test_utils_python.pyindex fa77356de..a5f183e6e 100644--- a/tests/test_utils_python.py+++ b/tests/test_utils_python.py@@ -12,10 +12,10 @@ __doctests__ = ['scrapy.utils.python']class ToUnicodeTest(unittest.TestCase):def test_converting_an_utf8_encoded_string_to_unicode(self):- self.assertEqual(to_unicode('lel\xc3\xb1e'), u'lel\xf1e')+ self.assertEqual(to_unicode(b'lel\xc3\xb1e'), u'lel\xf1e')def test_converting_a_latin_1_encoded_string_to_unicode(self):- self.assertEqual(to_unicode('lel\xf1e', 'latin-1'), u'lel\xf1e')+ self.assertEqual(to_unicode(b'lel\xf1e', 'latin-1'), u'lel\xf1e')def test_converting_a_unicode_to_unicode_should_return_the_same_object(self):self.assertEqual(to_unicode(u'\xf1e\xf1e\xf1e'), u'\xf1e\xf1e\xf1e')@@ -24,24 +24,24 @@ class ToUnicodeTest(unittest.TestCase):self.assertRaises(TypeError, to_unicode, 423)def test_check_errors_argument_works(self):- self.assertIn(u'\ufffd', to_unicode('a\xedb', 'utf-8', errors='replace'))+ self.assertIn(u'\ufffd', to_unicode(b'a\xedb', 'utf-8', errors='replace'))class ToBytesTest(unittest.TestCase):def test_converting_a_unicode_object_to_an_utf_8_encoded_string(self):- self.assertEqual(to_bytes(u'\xa3 49'), '\xc2\xa3 49')+ self.assertEqual(to_bytes(u'\xa3 49'), b'\xc2\xa3 49')def test_converting_a_unicode_object_to_a_latin_1_encoded_string(self):- self.assertEqual(to_bytes(u'\xa3 49', 'latin-1'), '\xa3 49')+ self.assertEqual(to_bytes(u'\xa3 49', 'latin-1'), b'\xa3 49')def test_converting_a_regular_string_to_string_should_return_the_same_object(self):- self.assertEqual(to_bytes('lel\xf1e'), 'lel\xf1e')+ self.assertEqual(to_bytes(b'lel\xf1e'), b'lel\xf1e')def test_converting_a_strange_object_should_raise_TypeError(self):self.assertRaises(TypeError, to_bytes, unittest)def test_check_errors_argument_works(self):- self.assertIn('?', to_bytes(u'a\ufffdb', 'latin-1', errors='replace'))+ self.assertIn(b'?', to_bytes(u'a\ufffdb', 'latin-1', errors='replace'))class UtilsPythonTestCase(unittest.TestCase):