Fix running tests with -n auto, enable it on CI (#7257)

* Make test_start_deprecated_super() more robust.

* Work around the FTPFilesStore.FTP_* initialization.

* Enable xdist on CI.

* Add PYTEST_ADDOPTS to tox passenv.
This commit is contained in:
Andrey Rakhmatullin 2026-02-13 20:12:57 +03:00 committed by GitHub
parent 09bd8f4231
commit 6e0a0e476a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 4 deletions

View File

@ -13,6 +13,8 @@ concurrency:
jobs:
tests:
runs-on: macos-latest
env:
PYTEST_ADDOPTS: -n auto
strategy:
fail-fast: false
matrix:

View File

@ -13,6 +13,8 @@ concurrency:
jobs:
tests:
runs-on: ubuntu-latest
env:
PYTEST_ADDOPTS: -n auto
strategy:
fail-fast: false
matrix:

View File

@ -13,6 +13,8 @@ concurrency:
jobs:
tests:
runs-on: windows-latest
env:
PYTEST_ADDOPTS: -n auto
strategy:
fail-fast: false
matrix:

View File

@ -700,6 +700,10 @@ class TestFTPFileStore:
meta = {"foo": "bar"}
path = "full/filename"
with MockFTPServer() as ftp_server:
# normally set via FilesPipeline.from_crawler()
FTPFilesStore.FTP_USERNAME = "anonymous"
FTPFilesStore.FTP_PASSWORD = "guest"
store = FTPFilesStore(ftp_server.url("/"))
empty_dict = yield store.stat_file(path, info=None)
assert empty_dict == {}

View File

@ -1,5 +1,6 @@
from __future__ import annotations
import re
import warnings
from asyncio import sleep
from typing import Any
@ -140,11 +141,16 @@ class TestMain:
for item_or_request in super().start_requests():
yield item_or_request
with pytest.warns(
ScrapyDeprecationWarning, match=r"use Spider\.start\(\) instead"
) as messages:
msg = "use Spider.start() instead"
with pytest.warns(ScrapyDeprecationWarning, match=re.escape(msg)) as ws:
await self._test_spider(TestSpider, [])
assert messages[0].filename.endswith("test_spider_start.py")
for w in ws:
if isinstance(w.message, ScrapyDeprecationWarning) and msg in str(
w.message
):
assert w.filename.endswith("test_spider_start.py")
break
async def _test_start(self, start_, expected_items=None):
class TestSpider(Spider):

View File

@ -26,6 +26,7 @@ deps =
{[test-requirements]deps}
pytest >= 8.4.1 # https://github.com/pytest-dev/pytest/pull/13502
passenv =
PYTEST_ADDOPTS
S3_TEST_FILE_URI
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY