Skip to content

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

Fix invalid XML samples in tests that break with lxml 6. (#6919)

Andrey Rakhmatullineaae59fbefc3
diff --git a/tests/spiders.py b/tests/spiders.py
index c47f2bd2b..43cdcaef3 100644
--- a/tests/spiders.py
+++ b/tests/spiders.py
@@ -418,7 +418,7 @@ class CrawlSpiderWithParseMethod(MockServerSpider, CrawlSpider):
async def start(self):
test_body = b"""
<html>
- <head><title>Page title<title></head>
+ <head><title>Page title</title></head>
<body>
<p><a href="/status?n=200">Item 200</a></p> <!-- callback -->
<p><a href="/status?n=201">Item 201</a></p> <!-- callback -->
@@ -472,7 +472,7 @@ class CrawlSpiderWithErrback(CrawlSpiderWithParseMethod):
async def start(self):
test_body = b"""
<html>
- <head><title>Page title<title></head>
+ <head><title>Page title</title></head>
<body>
<p><a href="/status?n=200">Item 200</a></p> <!-- callback -->
<p><a href="/status?n=201">Item 201</a></p> <!-- callback -->
diff --git a/tests/test_linkextractors.py b/tests/test_linkextractors.py
index 1bff369af..15d358d2a 100644
--- a/tests/test_linkextractors.py
+++ b/tests/test_linkextractors.py
@@ -152,7 +152,7 @@ class Base:
def test_nofollow(self):
"""Test the extractor's behaviour for links with rel='nofollow'"""
- html = b"""<html><head><title>Page title<title>
+ html = b"""<html><head><title>Page title</title></head>
<body>
<div class='links'>
<p><a href="/about.html">About us</a></p>
@@ -232,7 +232,7 @@ class Base:
def test_restrict_xpaths_encoding(self):
"""Test restrict_xpaths with encodings"""
- html = b"""<html><head><title>Page title<title>
+ html = b"""<html><head><title>Page title</title></head>
<body><p><a href="item/12.html">Item 12</a></p>
<div class='links'>
<p><a href="/about.html">About us\xa3</a></p>
@@ -378,7 +378,7 @@ class Base:
]
def test_base_url_with_restrict_xpaths(self):
- html = b"""<html><head><title>Page title<title><base href="http://otherdomain.com/base/" />
+ html = b"""<html><head><title>Page title</title><base href="http://otherdomain.com/base/" /></head>
<body><p><a href="item/12.html">Item 12</a></p>
</body></html>"""
response = HtmlResponse("http://example.org/somepage/index.html", body=html)
diff --git a/tests/test_spider.py b/tests/test_spider.py
index 4e4a99638..dceb9f91d 100644
--- a/tests/test_spider.py
+++ b/tests/test_spider.py
@@ -234,7 +234,7 @@ class TestCSVFeedSpider(TestSpider):
class TestCrawlSpider(TestSpider):
- test_body = b"""<html><head><title>Page title<title>
+ test_body = b"""<html><head><title>Page title</title></head>
<body>
<p><a href="item/12.html">Item 12</a></p>
<div class='links'>