-
Notifications
You must be signed in to change notification settings - Fork 572
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Increase config coverage. items() cannot raise NoOptionError.
- Loading branch information
1 parent
632fe3c
commit f144395
Showing
2 changed files
with
57 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from configparser import NoOptionError, NoSectionError | ||
|
||
import pytest | ||
|
||
from scrapyd.config import Config | ||
|
||
|
||
def test_items_no_section(): | ||
with pytest.raises(NoSectionError): | ||
Config().items("nonexistent") | ||
|
||
|
||
def test_get_no_section(): | ||
with pytest.raises(NoOptionError): | ||
Config().get("nonexistent") | ||
|
||
|
||
def test_get_no_option(): | ||
config = Config() | ||
config.cp.set("scrapyd", "http_port", "8000") | ||
|
||
with pytest.raises(NoOptionError): | ||
config.get("nonexistent") | ||
|
||
|
||
def test_closest_scrapy_cfg(monkeypatch, tmp_path): | ||
monkeypatch.chdir(tmp_path) | ||
(tmp_path / "scrapy.cfg").write_text("[scrapyd]\nhttp_port = 1234") | ||
|
||
assert Config().getint("http_port") == 1234 |