Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_conversion_from_path_using_dir_14(self):
start_time = time.time()
with TemporaryDirectory() as path:
images_from_path = convert_from_path(
"./tests/test_14.pdf", output_folder=path
)
self.assertTrue(len(images_from_path) == 14)
[im.close() for im in images_from_path]
print(
"test_conversion_from_path_using_dir_14: {} sec".format(
(time.time() - start_time) / 14.0
)
def test_pdfinfo_not_installed_throws(self):
start_time = time.time()
try:
images_from_path = convert_from_path("./tests/test_14.pdf")
raise Exception("This should not happen")
except PDFInfoNotInstalledError as ex:
pass
print(
"test_pdfinfo_not_installed_throws: {} sec".format(
(time.time() - start_time) / 14.0
)
def test_conversion_from_path_using_dir_14_first_page_12(self):
start_time = time.time()
with TemporaryDirectory() as path:
images_from_path = convert_from_path(
"./tests/test_14.pdf", output_folder=path, first_page=12
)
self.assertTrue(len(images_from_path) == 3)
[im.close() for im in images_from_path]
print(
"test_conversion_from_path_using_dir_14_first_page_12: {} sec".format(
(time.time() - start_time) / 14.0
)
def test_conversion_from_path_14_first_page_12_last_page_1(self):
start_time = time.time()
images_from_path = convert_from_path(
"./tests/test_14.pdf", first_page=12, last_page=1
)
self.assertTrue(len(images_from_path) == 0)
print(
"test_conversion_from_path_14: {} sec".format(
(time.time() - start_time) / 14.0
)
def test_conversion_from_pathlib_path_14(self):
start_time = time.time()
images_from_path = convert_from_path(pathlib.Path("./tests/test_14.pdf"))
self.assertTrue(len(images_from_path) == 14)
print(
"test_conversion_from_pathlib_path_14: {} sec".format(
(time.time() - start_time) / 14.0
)
def test_conversion_from_path_14_last_page_12(self):
start_time = time.time()
images_from_path = convert_from_path("./tests/test_14.pdf", last_page=12)
self.assertTrue(len(images_from_path) == 12)
print(
"test_conversion_from_path_14_last_page_12: {} sec".format(
(time.time() - start_time) / 14.0
)
def test_conversion_from_path_14_with_4_threads(self):
start_time = time.time()
images_from_path = convert_from_path("./tests/test_14.pdf", thread_count=4)
self.assertTrue(len(images_from_path) == 14)
print(
"test_conversion_from_path_14_with_4_thread: {} sec".format(
(time.time() - start_time) / 14.0
)
def test_conversion_from_bytes_14_last_page_12(self):
start_time = time.time()
with open("./tests/test_14.pdf", "rb") as pdf_file:
images_from_bytes = convert_from_bytes(pdf_file.read(), last_page=12)
self.assertTrue(len(images_from_bytes) == 12)
print(
"test_conversion_from_bytes_14_last_page_12: {} sec".format(
(time.time() - start_time) / 14.0
)
def test_not_locked_pdf(self):
start_time = time.time()
with TemporaryDirectory() as path:
with open("./tests/test.pdf", "rb") as pdf_file:
images_from_bytes = convert_from_bytes(
pdf_file.read(), output_folder=path, fmt=".jpg", userpw="pdf2image"
)
self.assertTrue(len(images_from_bytes) == 1)
[im.close() for im in images_from_bytes]
print(
"test_locked_pdf_with_userpw_only: {} sec".format(time.time() - start_time)
)
def test_conversion_from_bytes_14(self):
start_time = time.time()
with open("./tests/test_14.pdf", "rb") as pdf_file:
images_from_bytes = convert_from_bytes(pdf_file.read())
self.assertTrue(len(images_from_bytes) == 14)
print(
"test_conversion_from_bytes_14: {} sec".format(
(time.time() - start_time) / 14.0
)