Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/doc8/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ def validate(cfg, files, result=None):
f = files.popleft()
if cfg.get("verbose"):
print("Validating %s" % f)
targeted_ignoreables = set(ignore_targeted.get(f.filename, set()))
targeted_ignoreables = set(
ignore_targeted.get(os.path.abspath(f.filename), set()),
)
targeted_ignoreables.update(ignoreables)
for c in fetch_checks(cfg):
check_name = ".".join([c.__class__.__module__, c.__class__.__name__])
Expand Down
29 changes: 29 additions & 0 deletions src/doc8/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import shutil
import sys
import unittest
from collections import deque
from io import StringIO
from unittest.mock import MagicMock, patch

from doc8.checks import ContentCheck
from doc8.main import doc8, from_toml, main
from doc8.parser import ParsedFile

# Location to create test files
TMPFS_DIR_NAME = ".tmp"
Expand Down Expand Up @@ -365,6 +368,32 @@ def test_args__ignore_path_errors__overrides_default(self):
),
)

def test_args__ignore_path_errors__resolves_path(self):
mock_check = MagicMock(spec=ContentCheck)
mock_check.report_iter.return_value = [(40, "D002", "Testing")]
mock_fetch_checks = MagicMock(return_value=[mock_check])
mock_parsed_file = MagicMock(spec=ParsedFile)
mock_parsed_file.filename = "path"
mock_scan = MagicMock(return_value=(deque([mock_parsed_file]), 0))
with (
patch("doc8.main.fetch_checks", mock_fetch_checks),
patch("doc8.main.scan", mock_scan),
patch(
"argparse._sys.argv",
["doc8", "--ignore-path-errors", "path;D002"],
),
):
state = main()
self.assertEqual(state, 0)
mock_scan.assert_called_once_with(
self.get_args(
ignore_path_errors={"path": {"D002"}},
),
)
mock_fetch_checks.assert_called_once()
mock_check.report_iter.assert_called()
mock_check.assert_not_called()

def test_args__default_extension__overrides_default(self):
mock_scan = MagicMock(return_value=([], 0))
with (
Expand Down
Loading