From ddafb37a7c6c5c55b8736ce4040b5f50711bf952 Mon Sep 17 00:00:00 2001 From: Andrey Rakhmatullin Date: Wed, 10 Jun 2026 14:01:06 +0500 Subject: [PATCH] Assorted test fixes (#7585) * Fix the mitmproxy junitxml file name. * Fix TestAsyncCrawlerRunnerHasSpider regression. * Update split out file refs. * Update the test_counter_handler() docstring. --- conftest.py | 8 ++++---- tests/test_crawler.py | 4 ++-- tests/test_zz_resources.py | 3 ++- tox.ini | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/conftest.py b/conftest.py index 1674086ec..cf0568111 100644 --- a/conftest.py +++ b/conftest.py @@ -24,13 +24,13 @@ def _py_files(folder): collect_ignore = [ # may need extra deps "docs/_ext", - # contains scripts to be run by tests/test_crawler.py::AsyncCrawlerProcessSubprocess + # contains scripts to be run by tests/test_crawler_subprocess.py::AsyncCrawlerProcessSubprocess *_py_files("tests/AsyncCrawlerProcess"), - # contains scripts to be run by tests/test_crawler.py::AsyncCrawlerRunnerSubprocess + # contains scripts to be run by tests/test_crawler_subprocess.py::AsyncCrawlerRunnerSubprocess *_py_files("tests/AsyncCrawlerRunner"), - # contains scripts to be run by tests/test_crawler.py::CrawlerProcessSubprocess + # contains scripts to be run by tests/test_crawler_subprocess.py::CrawlerProcessSubprocess *_py_files("tests/CrawlerProcess"), - # contains scripts to be run by tests/test_crawler.py::CrawlerRunnerSubprocess + # contains scripts to be run by tests/test_crawler_subprocess.py::CrawlerRunnerSubprocess *_py_files("tests/CrawlerRunner"), ] diff --git a/tests/test_crawler.py b/tests/test_crawler.py index 853d6cfaa..3cde38a6f 100644 --- a/tests/test_crawler.py +++ b/tests/test_crawler.py @@ -764,8 +764,8 @@ class TestCrawlerRunnerHasSpider: @pytest.mark.only_asyncio class TestAsyncCrawlerRunnerHasSpider(TestCrawlerRunnerHasSpider): - @staticmethod - def _runner() -> CrawlerRunnerBase: + @pytest.fixture + def runner(self) -> CrawlerRunnerBase: return AsyncCrawlerRunner(get_reactor_settings()) def test_crawler_runner_asyncio_enabled_true(self) -> None: # type: ignore[override] diff --git a/tests/test_zz_resources.py b/tests/test_zz_resources.py index a8292745d..b2ba013f1 100644 --- a/tests/test_zz_resources.py +++ b/tests/test_zz_resources.py @@ -15,7 +15,8 @@ from tests.utils.decorators import coroutine_test def test_counter_handler() -> None: """Test that ``LogCounterHandler`` is always properly removed. - It's added in ``Crawler.crawl{,_async}()`` and removed on engine_stopped. + It's added in ``LogCount.spider_opened()`` and removed in + ``LogCount.spider_closed()``. """ c = sum(1 for h in logging.root.handlers if isinstance(h, LogCounterHandler)) assert c == 0 diff --git a/tox.ini b/tox.ini index 602394761..e21e1f6cf 100644 --- a/tox.ini +++ b/tox.ini @@ -307,4 +307,4 @@ deps = mitmproxy; implementation_name != "pypy" httpx[http2,socks] commands = - pytest {posargs:--cov-config=pyproject.toml --cov=scrapy --cov-report=xml --cov-report= tests --junitxml=botocore.junit.xml -o junit_family=legacy} -m requires_mitmproxy + pytest {posargs:--cov-config=pyproject.toml --cov=scrapy --cov-report=xml --cov-report= tests --junitxml=mitmproxy.junit.xml -o junit_family=legacy} -m requires_mitmproxy