Skip to content

Commit 7151f90

Browse files
Merge pull request #460 from afuetterer/detector-tests
test: add tests for `tika.detector`
2 parents 7a9c3a3 + d9b6d2a commit 7151f90

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_detector.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from pathlib import Path
2+
3+
from tika import detector
4+
5+
6+
TEST_FILE_PATH = Path(__file__).parent / "files" / "rwservlet.pdf"
7+
8+
9+
def test_local_binary():
10+
with open(TEST_FILE_PATH, "rb") as file_obj:
11+
assert detector.from_file(file_obj) == "application/pdf"
12+
13+
14+
def test_local_path():
15+
assert detector.from_file(str(TEST_FILE_PATH)) == "application/pdf"
16+
17+
18+
def test_local_buffer():
19+
assert detector.from_buffer("Good evening, David. How are you?") == "text/plain"

0 commit comments

Comments
 (0)