diff --git a/src/caoscrawler/converters/converters.py b/src/caoscrawler/converters/converters.py index da752f685ab3106f8dc8bc1226f1c7c3143ec4f1..df0d77b1184a7a9418ccd0be292a7b4c452a8e6b 100644 --- a/src/caoscrawler/converters/converters.py +++ b/src/caoscrawler/converters/converters.py @@ -831,13 +831,13 @@ class DirectoryConverter(Converter): stamp_str = ref_file.readline().strip() try: return datetime.datetime.fromisoformat(stamp_str) - except ValueError: - logger.warn( + except ValueError as e: + logger.error( f"Reference file in {self.definition['match_newer_than_file']} " "doesn't contain a ISO formatted datetime in its first line. " "Match regardless of modification times." ) - return datetime.datetime.min + raise e class SimpleFileConverter(Converter): diff --git a/unittests/test_converters.py b/unittests/test_converters.py index 7b22aa84646729caea171e14666ea1dd843b5ed6..e4b442d91060c7ba98cb1a910156b1800f050be3 100644 --- a/unittests/test_converters.py +++ b/unittests/test_converters.py @@ -1113,9 +1113,10 @@ def test_directory_converter_change_date(caplog, converter_registry): # Match but warn with open(tmpfi.name, "w") as fi: fi.write(f"This is garbage.\n") - assert dc.match(test_dir_element) is not None + with pytest.raises(ValueError): + dc.match(test_dir_element) assert len(caplog.record_tuples) == 1 - assert caplog.record_tuples[0][1] == logging.WARNING + assert caplog.record_tuples[0][1] == logging.ERROR assert tmpfi.name in caplog.record_tuples[0][2] assert "doesn't contain a ISO formatted datetime in its first line" in caplog.record_tuples[0][2]