mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-06-27 02:30:08 +00:00

**Summary** Improve file-detection tests in preparation for additional work and bug fixes. **Additional Context** - Add type annotations. - Use mocks instead of `monkeypatch` in most cases and verify calls to mock. This revealed a dozen broken tests, broken in that the mocks weren't being called so a different code path than intended was being exercised. - Use `example_doc_path()` instead of hard-coded paths. - Add actual test files for cases where they were being constructed in temporary directories. - Make test names consistent and more descriptive of behavior under test.
20 lines
540 B
Python
20 lines
540 B
Python
import logging
|
|
from typing import Any
|
|
|
|
logger = logging.getLogger("unstructured")
|
|
trace_logger = logging.getLogger("unstructured.trace")
|
|
|
|
# Create a custom logging level
|
|
DETAIL = 15
|
|
logging.addLevelName(DETAIL, "DETAIL")
|
|
|
|
|
|
# Create a custom log method for the "DETAIL" level
|
|
def detail(self: logging.Logger, message: str, *args: Any, **kwargs: Any):
|
|
if self.isEnabledFor(DETAIL):
|
|
self._log(DETAIL, message, args, **kwargs)
|
|
|
|
|
|
# Add the custom log method to the logging.Logger class
|
|
logging.Logger.detail = detail # type: ignore
|