Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions tika/tests/memory_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,11 @@
# python tika/tests/memory_benchmark.py
import os
import zlib

import gzip

import tika.parser
import tika.tika
from memory_profiler import profile

from tika.tests.utils import gzip_compress


@profile
def test_parser_binary():
Expand Down Expand Up @@ -62,7 +59,7 @@ def test_parser_gzip():
file = os.path.join(os.path.dirname(__file__), 'files', 'rwservlet.pdf')

with open(file, 'rb') as file_obj:
response = tika.parser.from_buffer(gzip_compress(file_obj.read()), headers={'Accept-Encoding': 'gzip, deflate'})
response = tika.parser.from_buffer(gzip.compress(file_obj.read()), headers={'Accept-Encoding': 'gzip, deflate'})

if __name__ == '__main__':
test_parser_buffer()
Expand Down
22 changes: 11 additions & 11 deletions tika/tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@
import os
import unittest
import zlib
import gzip
from http import HTTPStatus

import tika.parser
import tika.tika
from tika.tests.utils import HTTPStatusOk, gzip_compress


def test_local_binary(benchmark):
"""parse file binary"""
file = os.path.join(os.path.dirname(__file__), 'files', 'rwservlet.pdf')
response = benchmark(tika_from_binary, file)

assert response['status'] == HTTPStatusOk
assert response['status'] == HTTPStatus.OK


def test_parser_buffer(benchmark):
"""example how to send gzip file"""
file = os.path.join(os.path.dirname(__file__), 'files', 'rwservlet.pdf')
response = benchmark(tika_from_buffer, file)

assert response['status'] == HTTPStatusOk
assert response['status'] == HTTPStatus.OK


def test_parser_buffer_zlib_input(benchmark):
Expand All @@ -48,31 +48,31 @@ def test_parser_buffer_zlib_input(benchmark):

response = benchmark(tika_from_buffer_zlib, file)

assert response['status'] == HTTPStatusOk
assert response['status'] == HTTPStatus.OK


def test_parser_buffer_gzip_input(benchmark):
"""parse file binary"""
file = os.path.join(os.path.dirname(__file__), 'files', 'rwservlet.pdf')
response = benchmark(tika_from_buffer_gzip, file)

assert response['status'] == HTTPStatusOk
assert response['status'] == HTTPStatus.OK


def test_local_binary_with_gzip_output(benchmark):
"""parse file binary"""
file = os.path.join(os.path.dirname(__file__), 'files', 'rwservlet.pdf')
response = benchmark(tika_from_binary, file, headers={'Accept-Encoding': 'gzip, deflate'})

assert response['status'] == HTTPStatusOk
assert response['status'] == HTTPStatus.OK


def test_parser_buffer_with_gzip_output(benchmark):
"""example how to send gzip file"""
file = os.path.join(os.path.dirname(__file__), 'files', 'rwservlet.pdf')
response = benchmark(tika_from_buffer, file, headers={'Accept-Encoding': 'gzip, deflate'})

assert response['status'] == HTTPStatusOk
assert response['status'] == HTTPStatus.OK


def test_parser_buffer_zlib_input_and_gzip_output(benchmark):
Expand All @@ -81,15 +81,15 @@ def test_parser_buffer_zlib_input_and_gzip_output(benchmark):

response = benchmark(tika_from_buffer_zlib, file, headers={'Accept-Encoding': 'gzip, deflate'})

assert response['status'] == HTTPStatusOk
assert response['status'] == HTTPStatus.OK


def test_parser_buffer_gzip_input_and_gzip_output(benchmark):
"""parse file binary"""
file = os.path.join(os.path.dirname(__file__), 'files', 'rwservlet.pdf')
response = benchmark(tika_from_buffer_gzip, file, headers={'Accept-Encoding': 'gzip, deflate'})

assert response['status'] == HTTPStatusOk
assert response['status'] == HTTPStatus.OK


def tika_from_buffer_zlib(file, headers=None):
Expand All @@ -99,7 +99,7 @@ def tika_from_buffer_zlib(file, headers=None):

def tika_from_buffer_gzip(file, headers=None):
with open(file, 'rb') as file_obj:
return tika.parser.from_buffer(gzip_compress(file_obj.read()), headers=headers)
return tika.parser.from_buffer(gzip.compress(file_obj.read()), headers=headers)


def tika_from_buffer(file, headers=None):
Expand Down
4 changes: 2 additions & 2 deletions tika/tests/test_tika.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import os
import unittest
from http import HTTPStatus

import tika.parser
import tika.tika
from tika.tests.utils import HTTPStatusOk


class CreateTest(unittest.TestCase):
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_local_binary(self):

def test_local_buffer(self):
response = tika.parser.from_buffer('Good evening, Dave')
self.assertEqual(response['status'], HTTPStatusOk)
self.assertEqual(response['status'], HTTPStatus.OK)

def test_local_path(self):
"""parse file path"""
Expand Down
55 changes: 0 additions & 55 deletions tika/tests/utils.py

This file was deleted.

Loading