From 42594a571579402ff4afbc4e6d795386594af855 Mon Sep 17 00:00:00 2001 From: Adrien Barbaresi Date: Thu, 28 Nov 2024 15:23:14 +0100 Subject: [PATCH] tests: better coverage --- htmldate/extractors.py | 4 ++-- tests/unit_tests.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htmldate/extractors.py b/htmldate/extractors.py index b8ffd8aa..2433ff16 100644 --- a/htmldate/extractors.py +++ b/htmldate/extractors.py @@ -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): @@ -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 diff --git a/tests/unit_tests.py b/tests/unit_tests.py index 6cfbcd5b..190c0ed5 100644 --- a/tests/unit_tests.py +++ b/tests/unit_tests.py @@ -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 (