diff --git a/tests/__init__.py b/tests/__init__.py index ee54efb2..12e4b861 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -2,7 +2,9 @@ from os import environ from typing import Any, Dict, Optional +from packaging.version import Version from scrapy import Spider +from scrapy import __version__ as SCRAPY_VERSION from scrapy.crawler import Crawler from scrapy.utils.misc import load_object from scrapy.utils.test import get_crawler as _get_crawler @@ -25,13 +27,16 @@ "scrapy_zyte_api.ScrapyZyteAPISessionDownloaderMiddleware": 667, }, "REQUEST_FINGERPRINTER_CLASS": "scrapy_zyte_api.ScrapyZyteAPIRequestFingerprinter", - "REQUEST_FINGERPRINTER_IMPLEMENTATION": "2.7", # Silence deprecation warning "SPIDER_MIDDLEWARES": { "scrapy_zyte_api.ScrapyZyteAPISpiderMiddleware": 100, }, "ZYTE_API_KEY": _API_KEY, "TWISTED_REACTOR": "twisted.internet.asyncioreactor.AsyncioSelectorReactor", } +if Version(SCRAPY_VERSION) < Version("2.12"): + SETTINGS["REQUEST_FINGERPRINTER_IMPLEMENTATION"] = ( + "2.7" # Silence deprecation warning + ) try: import scrapy_poet # noqa: F401 except ImportError: