mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
fix #501
This commit is contained in:
parent
88fba4ee98
commit
fa13386899
@ -255,7 +255,6 @@ void check_param()
|
|||||||
if(get_suffix(param.input_filename) == ".pdf")
|
if(get_suffix(param.input_filename) == ".pdf")
|
||||||
{
|
{
|
||||||
param.output_filename = s.substr(0, s.size() - 4) + ".html";
|
param.output_filename = s.substr(0, s.size() - 4) + ".html";
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -298,7 +297,6 @@ void check_param()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!param.split_pages)
|
|
||||||
param.css_filename = s + ".css";
|
param.css_filename = s + ".css";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,14 +100,13 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
test_names = []
|
test_names = []
|
||||||
for name in sys.argv[1:]:
|
for name in sys.argv[1:]:
|
||||||
if name.find('.') != -1:
|
|
||||||
test_names.append(name)
|
test_names.append(name)
|
||||||
else:
|
if name.find('.') == -1:
|
||||||
for m in all_classes:
|
for m in all_classes:
|
||||||
test_names.append(m + '.' + name)
|
test_names.append(m + '.' + name)
|
||||||
|
|
||||||
for module in all_modules:
|
for module in all_modules:
|
||||||
if len(test_names) > 0:
|
if len(test_names) > 0 and module.__name__ not in test_names:
|
||||||
for n in test_names:
|
for n in test_names:
|
||||||
try:
|
try:
|
||||||
suites.append(loader.loadTestsFromName(n, module))
|
suites.append(loader.loadTestsFromName(n, module))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Test output files
|
# Check pdf2htmlEX does not crash, and produces correct files.
|
||||||
|
# Do not check the content of the files
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import os
|
import os
|
||||||
@ -9,78 +10,82 @@ from test import Common
|
|||||||
|
|
||||||
@unittest.skipIf(Common.GENERATING_MODE, 'Skipping test_output in generating mode')
|
@unittest.skipIf(Common.GENERATING_MODE, 'Skipping test_output in generating mode')
|
||||||
class test_output(Common, unittest.TestCase):
|
class test_output(Common, unittest.TestCase):
|
||||||
def run_test_case(self, input_file, expected_output_files, args=[]):
|
def run_test_case(self, input_file, args=[], expected_output_files=None):
|
||||||
args = list(args)
|
args = list(args)
|
||||||
args.insert(0, os.path.join(self.TEST_DIR, 'test_output', input_file))
|
args.insert(0, os.path.join(self.TEST_DIR, 'test_output', input_file))
|
||||||
self.assertItemsEqual(self.run_pdf2htmlEX(args)['output_files'], expected_output_files)
|
result = self.run_pdf2htmlEX(args)
|
||||||
|
print result
|
||||||
|
if expected_output_files:
|
||||||
|
self.assertItemsEqual(result['output_files'], expected_output_files)
|
||||||
|
|
||||||
def test_generate_single_html_default_name_single_page_pdf(self):
|
def test_generate_single_html_default_name_single_page_pdf(self):
|
||||||
self.run_test_case('1-page.pdf', ['1-page.html'])
|
self.run_test_case('1-page.pdf', expected_output_files = ['1-page.html'])
|
||||||
|
|
||||||
def test_generate_single_html_default_name_multiple_page_pdf(self):
|
def test_generate_single_html_default_name_multiple_page_pdf(self):
|
||||||
self.run_test_case('2-pages.pdf', ['2-pages.html'])
|
self.run_test_case('2-pages.pdf', expected_output_files = ['2-pages.html'])
|
||||||
|
|
||||||
def test_generate_single_html_specify_name_single_page_pdf(self):
|
def test_generate_single_html_specify_name_single_page_pdf(self):
|
||||||
self.run_test_case('1-page.pdf', ['foo.html'], ['foo.html'])
|
self.run_test_case('1-page.pdf', ['foo.html'], expected_output_files = ['foo.html'])
|
||||||
|
|
||||||
def test_generate_single_html_specify_name_multiple_page_pdf(self):
|
def test_generate_single_html_specify_name_multiple_page_pdf(self):
|
||||||
self.run_test_case('2-pages.pdf', ['foo.html'], ['foo.html'])
|
self.run_test_case('2-pages.pdf', ['foo.html'], expected_output_files = ['foo.html'])
|
||||||
|
|
||||||
def test_generate_split_pages_default_name_single_page(self):
|
def test_generate_split_pages_default_name_single_page(self):
|
||||||
self.run_test_case('1-page.pdf', ['1-page.html', '1-page1.page'], ['--split-pages', 1])
|
self.run_test_case('1-page.pdf', ['--split-pages', 1], expected_output_files = ['1-page.html', '1-page1.page'])
|
||||||
|
|
||||||
def test_generate_split_pages_default_name_multiple_pages(self):
|
def test_generate_split_pages_default_name_multiple_pages(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', '3-pages1.page', '3-pages2.page', '3-pages3.page'], ['--split-pages', 1])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1], expected_output_files = ['3-pages.html', '3-pages1.page', '3-pages2.page', '3-pages3.page'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_single_page(self):
|
def test_generate_split_pages_specify_name_single_page(self):
|
||||||
self.run_test_case('1-page.pdf', ['1-page.html', 'foo1.xyz'], ['--split-pages', 1, '--page-filename', 'foo.xyz'])
|
self.run_test_case('1-page.pdf', ['--split-pages', 1, '--page-filename', 'foo.xyz'], expected_output_files = ['1-page.html', 'foo1.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_multiple_pages(self):
|
def test_generate_split_pages_specify_name_multiple_pages(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'foo1.xyz', 'foo2.xyz', 'foo3.xyz'], ['--split-pages', 1, '--page-filename', 'foo.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'foo.xyz'], expected_output_files = ['3-pages.html', 'foo1.xyz', 'foo2.xyz', 'foo3.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_formatter_multiple_pages(self):
|
def test_generate_split_pages_specify_name_formatter_multiple_pages(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo1o.xyz', 'fo2o.xyz', 'fo3o.xyz'], ['--split-pages', 1, '--page-filename', 'fo%do.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'fo%do.xyz'], expected_output_files = ['3-pages.html', 'fo1o.xyz', 'fo2o.xyz', 'fo3o.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_formatter_with_padded_zeros_multiple_pages(self):
|
def test_generate_split_pages_specify_name_formatter_with_padded_zeros_multiple_pages(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo001o.xyz', 'fo002o.xyz', 'fo003o.xyz'], ['--split-pages', 1, '--page-filename', 'fo%03do.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'fo%03do.xyz'], expected_output_files = ['3-pages.html', 'fo001o.xyz', 'fo002o.xyz', 'fo003o.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_only_first_formatter_gets_taken(self):
|
def test_generate_split_pages_specify_name_only_first_formatter_gets_taken(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f1o%do.xyz', 'f2o%do.xyz', 'f3o%do.xyz'], ['--split-pages', 1, '--page-filename', 'f%do%do.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%do%do.xyz'], expected_output_files = ['3-pages.html', 'f1o%do.xyz', 'f2o%do.xyz', 'f3o%do.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_s(self):
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_s(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%soo1.xyz', 'f%soo2.xyz', 'f%soo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%soo.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%soo.xyz'], expected_output_files = ['3-pages.html', 'f%soo1.xyz', 'f%soo2.xyz', 'f%soo3.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_p(self):
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_p(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%poo1.xyz', 'f%poo2.xyz', 'f%poo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%poo.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%poo.xyz'], expected_output_files = ['3-pages.html', 'f%poo1.xyz', 'f%poo2.xyz', 'f%poo3.xyz'])
|
||||||
|
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_n(self):
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_n(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%noo1.xyz', 'f%noo2.xyz', 'f%noo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%noo.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%noo.xyz'], expected_output_files = ['3-pages.html', 'f%noo1.xyz', 'f%noo2.xyz', 'f%noo3.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent(self):
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%%oo1.xyz', 'f%%oo2.xyz', 'f%%oo3.xyz'], ['--split-pages', 1, '--page-filename', 'f%%oo.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%%oo.xyz'], expected_output_files = ['3-pages.html', 'f%%oo1.xyz', 'f%%oo2.xyz', 'f%%oo3.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent_with_actual_placeholder(self):
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent_with_actual_placeholder(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%%o1o.xyz', 'f%%o2o.xyz', 'f%%o3o.xyz'], ['--split-pages', 1, '--page-filename', 'f%%o%do.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%%o%do.xyz'], expected_output_files = ['3-pages.html', 'f%%o1o.xyz', 'f%%o2o.xyz', 'f%%o3o.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent_with_actual_placeholder(self):
|
def test_generate_split_pages_specify_name_only_percent_d_is_used_percent_percent_with_actual_placeholder(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'fo1o%%.xyz', 'fo2o%%.xyz', 'fo3o%%.xyz'], ['--split-pages', 1, '--page-filename', 'fo%do%%.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'fo%do%%.xyz'], expected_output_files = ['3-pages.html', 'fo1o%%.xyz', 'fo2o%%.xyz', 'fo3o%%.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_name_only_formatter_starts_part_way_through_invalid_formatter(self):
|
def test_generate_split_pages_specify_name_only_formatter_starts_part_way_through_invalid_formatter(self):
|
||||||
self.run_test_case('3-pages.pdf', ['3-pages.html', 'f%021oo.xyz', 'f%022oo.xyz', 'f%023oo.xyz'], ['--split-pages', 1, '--page-filename', 'f%02%doo.xyz'])
|
self.run_test_case('3-pages.pdf', ['--split-pages', 1, '--page-filename', 'f%02%doo.xyz'], expected_output_files = ['3-pages.html', 'f%021oo.xyz', 'f%022oo.xyz', 'f%023oo.xyz'])
|
||||||
|
|
||||||
def test_generate_split_pages_specify_output_filename_no_formatter_no_extension(self):
|
def test_generate_split_pages_specify_output_filename_no_formatter_no_extension(self):
|
||||||
self.run_test_case('1-page.pdf', ['1-page.html', 'foo1'], ['--split-pages', 1, '--page-filename', 'foo'])
|
self.run_test_case('1-page.pdf', ['--split-pages', 1, '--page-filename', 'foo'], expected_output_files = ['1-page.html', 'foo1'])
|
||||||
|
|
||||||
def test_generate_single_html_name_specified_format_characters_percent_d(self):
|
def test_generate_single_html_name_specified_format_characters_percent_d(self):
|
||||||
self.run_test_case('2-pages.pdf', ['foo%d.html'], ['foo%d.html'])
|
self.run_test_case('2-pages.pdf', ['foo%d.html'], expected_output_files = ['foo%d.html'])
|
||||||
|
|
||||||
def test_generate_single_html_name_specified_format_characters_percent_p(self):
|
def test_generate_single_html_name_specified_format_characters_percent_p(self):
|
||||||
self.run_test_case('2-pages.pdf', ['foo%p.html'], ['foo%p.html'])
|
self.run_test_case('2-pages.pdf', ['foo%p.html'], expected_output_files = ['foo%p.html'])
|
||||||
|
|
||||||
def test_generate_single_html_name_specified_format_characters_percent_n(self):
|
def test_generate_single_html_name_specified_format_characters_percent_n(self):
|
||||||
self.run_test_case('2-pages.pdf', ['foo%n.html'], ['foo%n.html'])
|
self.run_test_case('2-pages.pdf', ['foo%n.html'], expected_output_files = ['foo%n.html'])
|
||||||
|
|
||||||
def test_generate_single_html_name_specified_format_characters_percent_percent(self):
|
def test_generate_single_html_name_specified_format_characters_percent_percent(self):
|
||||||
self.run_test_case('2-pages.pdf', ['foo%%.html'], ['foo%%.html'])
|
self.run_test_case('2-pages.pdf', ['foo%%.html'], expected_output_files = ['foo%%.html'])
|
||||||
|
|
||||||
|
def test_issue501(self):
|
||||||
|
self.run_test_case('issue501', ['--split-pages', 1, '--embed-css', 0]);
|
||||||
|
BIN
test/test_output/issue501
Normal file
BIN
test/test_output/issue501
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user