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:
|
||||
tests:
|
||||
runs-on: macos-latest
|
||||
env:
|
||||
PYTEST_ADDOPTS: -n auto
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ concurrency:
|
|||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
PYTEST_ADDOPTS: -n auto
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ concurrency:
|
|||
jobs:
|
||||
tests:
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
PYTEST_ADDOPTS: -n auto
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
|
|
|
|||
|
|
@ -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 == {}
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue