From 6a0b82e2530bb6c0a9b87c8cbcacb8ba3052b356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Heinz-Alexander=20F=C3=BCtterer?= <35225576+afuetterer@users.noreply.github.com> Date: Thu, 12 Mar 2026 08:35:51 +0100 Subject: [PATCH] test: add tests for tika.detector --- tests/test_detector.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_detector.py diff --git a/tests/test_detector.py b/tests/test_detector.py new file mode 100644 index 0000000..f6271dc --- /dev/null +++ b/tests/test_detector.py @@ -0,0 +1,19 @@ +from pathlib import Path + +from tika import detector + + +TEST_FILE_PATH = Path(__file__).parent / "files" / "rwservlet.pdf" + + +def test_local_binary(): + with open(TEST_FILE_PATH, "rb") as file_obj: + assert detector.from_file(file_obj) == "application/pdf" + + +def test_local_path(): + assert detector.from_file(str(TEST_FILE_PATH)) == "application/pdf" + + +def test_local_buffer(): + assert detector.from_buffer("Good evening, David. How are you?") == "text/plain"