Skip to content

Commit

Permalink
Skip failing tests on older Scrapy due to a Scrapy bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Gallaecio committed Apr 16, 2024
1 parent c2d277e commit ed28606
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions tests/test_components_request.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import base64

import pytest
import scrapy
from packaging.version import Version

from zyte_common_items import Header, Request

_SCRAPY_VERSION = Version(scrapy.__version__)


def test_request_no_kwargs():
req = Request("http://example.com")
Expand All @@ -23,7 +27,6 @@ def test_request_body_bytes():


def test_request_to_scrapy_basic():
scrapy = pytest.importorskip("scrapy")
req = Request("http://example.com")
scrapy_req = req.to_scrapy(None)

Expand All @@ -34,7 +37,6 @@ def test_request_to_scrapy_basic():


def test_request_to_scrapy_complex():
scrapy = pytest.importorskip("scrapy")

def callback():
pass
Expand Down Expand Up @@ -62,11 +64,12 @@ def callback():
assert scrapy_req.priority == 5


@pytest.mark.skipif(
_SCRAPY_VERSION < Version("2.7.0"),
reason="https://github.com/scrapy/scrapy/issues/5515",
)
def test_request_to_scrapy_headers_with_the_same_name():
pytest.importorskip("scrapy")

headers = [Header(name="name", value="value1"), Header(name="name", value="value2")]

req = Request("http://example.com", headers=headers)
scrapy_req = req.to_scrapy(callback=None)
assert scrapy_req.headers.getlist("name") == [b"value1", b"value2"]
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ deps =
# For Jinja2:
markupsafe==1.1.1
price-parser==0.3.4
scrapy==2.0.1
web-poet==0.14.0
zyte-parsers==0.5.0
scrapy==2.7.0

[testenv:docs]
changedir = docs
Expand Down

0 comments on commit ed28606

Please sign in to comment.