Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

revert most changes to this test, and clarify - it is valid only on py2, because urls are strictly unicode on py3

Konstantin Lopuhin494643458270
diff --git a/tests/test_webclient.py b/tests/test_webclient.py
index dbe659d5c..9b5beda4c 100644
--- a/tests/test_webclient.py
+++ b/tests/test_webclient.py
@@ -78,16 +78,17 @@ class ParseUrlTestCase(unittest.TestCase):
elements of its return tuple, even when passed an URL which has
previously been passed to L{urlparse} as a C{unicode} string.
"""
- goodInput = u'http://example.com/path'
- badInput = goodInput.encode('ascii')
- if six.PY2:
- goodInput, badInput = badInput, goodInput
- urlparse(badInput)
+ if not six.PY2:
+ raise unittest.SkipTest(
+ "Applies only to Py2, as urls can be ONLY unicode on Py3")
+ badInput = u'http://example.com/path'
+ goodInput = badInput.encode('ascii')
+ self._parse(badInput) # cache badInput in urlparse_cached
scheme, netloc, host, port, path = self._parse(goodInput)
- self.assertTrue(isinstance(scheme, bytes))
- self.assertTrue(isinstance(netloc, bytes))
- self.assertTrue(isinstance(host, bytes))
- self.assertTrue(isinstance(path, bytes))
+ self.assertTrue(isinstance(scheme, str))
+ self.assertTrue(isinstance(netloc, str))
+ self.assertTrue(isinstance(host, str))
+ self.assertTrue(isinstance(path, str))
self.assertTrue(isinstance(port, int))