mirror of https://github.com/scrapy/scrapy.git
add test and update docs
This commit is contained in:
parent
5d565052ce
commit
1e844796c0
|
|
@ -21,17 +21,8 @@ standalone ``scrapyd-deploy``. See `Deploying your project`_.)
|
|||
Configuration settings
|
||||
======================
|
||||
|
||||
Scrapy will look for configuration parameters in toml-style ``pyproject.toml``
|
||||
files in standard locations:
|
||||
|
||||
1. ``/etc/pyproject.toml`` or ``c:\scrapy\pyproject.toml`` (system-wide),
|
||||
2. ``~/.config/pyproject.toml`` (``$XDG_CONFIG_HOME``) and ``~/.pyproject.toml`` (``$HOME``)
|
||||
for global (user-wide) settings, and
|
||||
3. ``pyproject.toml`` inside a Scrapy project's root (see next section).
|
||||
|
||||
Settings from these files are merged in the listed order of preference:
|
||||
user-defined values have higher priority than system-wide defaults
|
||||
and project-wide settings will override all others, when defined.
|
||||
Scrapy looks for project configuration in a ``pyproject.toml`` file located in
|
||||
the project root directory (see next section).
|
||||
|
||||
Scrapy also understands, and can be configured through, a number of environment
|
||||
variables. Currently these are:
|
||||
|
|
|
|||
|
|
@ -59,6 +59,19 @@ def test_arglist_to_dict():
|
|||
|
||||
|
||||
class TestPyprojectToml:
|
||||
def test_multiple_projects(self, tmp_path, monkeypatch):
|
||||
(tmp_path / "pyproject.toml").write_text(
|
||||
"[tool.scrapy.settings]\n"
|
||||
'default = "myproject1.settings"\n'
|
||||
'project1 = "myproject1.settings"\n'
|
||||
'project2 = "myproject2.settings"\n'
|
||||
)
|
||||
monkeypatch.chdir(tmp_path)
|
||||
cfg = get_config()
|
||||
assert cfg.get("settings", "default") == "myproject1.settings"
|
||||
assert cfg.get("settings", "project1") == "myproject1.settings"
|
||||
assert cfg.get("settings", "project2") == "myproject2.settings"
|
||||
|
||||
def test_pyproject_toml_takes_precedence_over_scrapy_cfg(
|
||||
self, tmp_path, monkeypatch
|
||||
):
|
||||
|
|
|
|||
Loading…
Reference in New Issue