mirror of https://github.com/scrapy/scrapy.git
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:
parent
09bd8f4231
commit
6e0a0e476a
|
|
@ -13,6 +13,8 @@ concurrency:
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
env:
|
||||||
|
PYTEST_ADDOPTS: -n auto
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ concurrency:
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
PYTEST_ADDOPTS: -n auto
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@ concurrency:
|
||||||
jobs:
|
jobs:
|
||||||
tests:
|
tests:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
env:
|
||||||
|
PYTEST_ADDOPTS: -n auto
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
|
|
||||||
|
|
@ -700,6 +700,10 @@ class TestFTPFileStore:
|
||||||
meta = {"foo": "bar"}
|
meta = {"foo": "bar"}
|
||||||
path = "full/filename"
|
path = "full/filename"
|
||||||
with MockFTPServer() as ftp_server:
|
with MockFTPServer() as ftp_server:
|
||||||
|
# normally set via FilesPipeline.from_crawler()
|
||||||
|
FTPFilesStore.FTP_USERNAME = "anonymous"
|
||||||
|
FTPFilesStore.FTP_PASSWORD = "guest"
|
||||||
|
|
||||||
store = FTPFilesStore(ftp_server.url("/"))
|
store = FTPFilesStore(ftp_server.url("/"))
|
||||||
empty_dict = yield store.stat_file(path, info=None)
|
empty_dict = yield store.stat_file(path, info=None)
|
||||||
assert empty_dict == {}
|
assert empty_dict == {}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import re
|
||||||
import warnings
|
import warnings
|
||||||
from asyncio import sleep
|
from asyncio import sleep
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
@ -140,11 +141,16 @@ class TestMain:
|
||||||
for item_or_request in super().start_requests():
|
for item_or_request in super().start_requests():
|
||||||
yield item_or_request
|
yield item_or_request
|
||||||
|
|
||||||
with pytest.warns(
|
msg = "use Spider.start() instead"
|
||||||
ScrapyDeprecationWarning, match=r"use Spider\.start\(\) instead"
|
with pytest.warns(ScrapyDeprecationWarning, match=re.escape(msg)) as ws:
|
||||||
) as messages:
|
|
||||||
await self._test_spider(TestSpider, [])
|
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):
|
async def _test_start(self, start_, expected_items=None):
|
||||||
class TestSpider(Spider):
|
class TestSpider(Spider):
|
||||||
|
|
|
||||||
1
tox.ini
1
tox.ini
|
|
@ -26,6 +26,7 @@ deps =
|
||||||
{[test-requirements]deps}
|
{[test-requirements]deps}
|
||||||
pytest >= 8.4.1 # https://github.com/pytest-dev/pytest/pull/13502
|
pytest >= 8.4.1 # https://github.com/pytest-dev/pytest/pull/13502
|
||||||
passenv =
|
passenv =
|
||||||
|
PYTEST_ADDOPTS
|
||||||
S3_TEST_FILE_URI
|
S3_TEST_FILE_URI
|
||||||
AWS_ACCESS_KEY_ID
|
AWS_ACCESS_KEY_ID
|
||||||
AWS_SECRET_ACCESS_KEY
|
AWS_SECRET_ACCESS_KEY
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue