Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adbar committed Jun 5, 2024
1 parent bd0b057 commit b9b1b4f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions htmldate/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ def is_valid_date(
@lru_cache(maxsize=16)
def is_valid_format(outputformat: str) -> bool:
"""Validate the output format in the settings"""
# test in abstracto
if not isinstance(outputformat, str) or "%" not in outputformat:
LOGGER.error("malformed output format: %s", outputformat)
return False
# test with date object
dateobject = datetime(2017, 9, 1, 0, 0)
try:
Expand All @@ -72,6 +68,10 @@ def is_valid_format(outputformat: str) -> bool:
except (NameError, TypeError, ValueError) as err:
LOGGER.error("wrong output format or type: %s %s", outputformat, err)
return False
# test in abstracto (could be the only test)
if not isinstance(outputformat, str) or "%" not in outputformat:
LOGGER.error("malformed output format: %s", outputformat)
return False
return True


Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ def test_sanity():
assert is_valid_format("ABC") is False
assert is_valid_format(123) is False
assert is_valid_format(("a", "b")) is False
# assert is_valid_format('%\xaa') is False
_, discarded = discard_unwanted(
html.fromstring(
'<html><body><div id="wm-ipp">000</div><div>AAA</div></body></html>'
Expand Down

0 comments on commit b9b1b4f

Please sign in to comment.