Skip to content

Commit

Permalink
tests: better coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
adbar committed Nov 28, 2024
1 parent 69fea3b commit 42594a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions htmldate/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ def custom_parse(
candidate = datetime(
int(match.group("year2")), int(match.group("month2")), 1
)
except ValueError: # pragma: no cover
except ValueError:
LOGGER.debug("Y-M value error: %s", match[0])
else:
if is_valid_date(candidate, "%Y-%m-%d", earliest=min_date, latest=max_date):
Expand All @@ -384,7 +384,7 @@ def custom_parse(
try:
LOGGER.debug("custom parse result: %s", dateobject)
return dateobject.strftime(outputformat) # type: ignore
except ValueError as err:
except ValueError as err: # pragma: no cover
LOGGER.error("value error during conversion: %s %s", string, err)

return None
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,8 @@ def test_regex_parse():
custom_parse("January 12 1098", OUTPUTFORMAT, MIN_DATE, LATEST_POSSIBLE) is None
)
assert custom_parse("1998-01", OUTPUTFORMAT, MIN_DATE, LATEST_POSSIBLE) is not None
assert custom_parse("01-1998", OUTPUTFORMAT, MIN_DATE, LATEST_POSSIBLE) is not None
assert custom_parse("13-1998", OUTPUTFORMAT, MIN_DATE, LATEST_POSSIBLE) is None
assert custom_parse("10.10.98", OUTPUTFORMAT, MIN_DATE, LATEST_POSSIBLE) is not None
assert custom_parse("12122004", OUTPUTFORMAT, MIN_DATE, LATEST_POSSIBLE) is None
assert (
Expand Down

0 comments on commit 42594a5

Please sign in to comment.