mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-23 08:24:16 +00:00
* Add a test for a CrawlerProcess script. * Add tests/CrawlerProcess to collect_ignore. * Remove an extra line. * Fix/improve conftest.py.
37 lines
953 B
Python
37 lines
953 B
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
def _py_files(folder):
|
|
return (str(p) for p in Path(folder).rglob('*.py'))
|
|
|
|
|
|
collect_ignore = [
|
|
# not a test, but looks like a test
|
|
"scrapy/utils/testsite.py",
|
|
# contains scripts to be run by tests/test_crawler.py::CrawlerProcessSubprocess
|
|
*_py_files("tests/CrawlerProcess")
|
|
]
|
|
|
|
for line in open('tests/ignores.txt'):
|
|
file_path = line.strip()
|
|
if file_path and file_path[0] != '#':
|
|
collect_ignore.append(file_path)
|
|
|
|
|
|
@pytest.fixture()
|
|
def chdir(tmpdir):
|
|
"""Change to pytest-provided temporary directory"""
|
|
tmpdir.chdir()
|
|
|
|
|
|
def pytest_collection_modifyitems(session, config, items):
|
|
# Avoid executing tests when executing `--flake8` flag (pytest-flake8)
|
|
try:
|
|
from pytest_flake8 import Flake8Item
|
|
if config.getoption('--flake8'):
|
|
items[:] = [item for item in items if isinstance(item, Flake8Item)]
|
|
except ImportError:
|
|
pass
|