1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

copy edit

This commit is contained in:
Joachim Wuttke (o) 2016-09-26 17:14:06 +02:00
parent e2b41a9297
commit 7be77ea1b9
2 changed files with 13 additions and 17 deletions

View File

@ -30,22 +30,20 @@ class BrowserTests(Common):
def run_test_case(self, filename, pdf2htmlEX_args=[], page_must_load=True):
basefilename, extension = os.path.splitext(filename)
htmlfilename = basefilename + '.html'
self.assertEquals(extension.lower(), '.pdf', 'Input file is not PDF')
htmlfilename = basefilename + '.html'
ref_htmlfolder = os.path.join(self.TEST_DATA_DIR, basefilename)
ref_htmlfilename = os.path.join(ref_htmlfolder, htmlfilename)
out_htmlfilename = os.path.join(self.OUTDIR, htmlfilename)
self.assertEquals(extension.lower(), '.pdf', 'Input file is not PDF')
pdf2htmlEX_args = self.DEFAULT_PDF2HTMLEX_ARGS \
+ list(pdf2htmlEX_args) + [
os.path.join(self.TEST_DATA_DIR, filename),
htmlfilename
]
result = self.run_pdf2htmlEX(pdf2htmlEX_args)
self.assertIn(htmlfilename, result['output_files'], 'HTML file is not generated')
if self.GENERATING_MODE:
@ -54,13 +52,13 @@ class BrowserTests(Common):
shutil.copytree(self.OUTDIR, ref_htmlfolder)
return
pngfilename_out_fullpath = os.path.join(self.PNGDIR, basefilename + '.out.png')
self.generate_image(out_htmlfilename, pngfilename_out_fullpath)
out_img = Image.open(pngfilename_out_fullpath)
pngfilename_out = os.path.join(self.PNGDIR, basefilename + '.out.png')
self.generate_image(out_htmlfilename, pngfilename_out)
out_img = Image.open(pngfilename_out)
pngfilename_ref_fullpath = os.path.join(self.PNGDIR, basefilename + '.ref.png')
self.generate_image(ref_htmlfilename, pngfilename_ref_fullpath, page_must_load=page_must_load)
ref_img = Image.open(pngfilename_ref_fullpath)
pngfilename_ref = os.path.join(self.PNGDIR, basefilename + '.ref.png')
self.generate_image(ref_htmlfilename, pngfilename_ref, page_must_load=page_must_load)
ref_img = Image.open(pngfilename_ref)
diff_img = ImageChops.difference(ref_img, out_img);
@ -68,14 +66,12 @@ class BrowserTests(Common):
if diff_bbox is not None:
diff_size = (diff_bbox[2] - diff_bbox[0]) * (diff_bbox[3] - diff_bbox[1])
img_size = ref_img.size[0] * ref_img.size[1]
diff_file_name = "<not saved>"
# save the diff image
# http://stackoverflow.com/questions/15721484/saving-in-png-using-pil-library-after-taking-imagechops-difference-of-two-png
# save the diff image (http://stackoverflow.com/questions/15721484):
diff_file_name = os.path.join(self.PNGDIR, basefilename + '.diff.png')
diff_img.convert('RGB').save(diff_file_name)
self.fail(('PNG files %s and %s differ by <= %d pixels, (%f%% of %d pixels in total), '+
'difference: %s') %
(pngfilename_out_fullpath, pngfilename_ref_fullpath,
(pngfilename_out, pngfilename_ref,
diff_size, 1.0*diff_size/img_size, img_size, diff_file_name))
@unittest.skipIf(Common.GENERATING_MODE, 'Do not auto generate reference for test_fail')

View File

@ -99,7 +99,7 @@ class test_remote_browser_base(BrowserTests):
passed = (sys.exc_info() == (None, None, None))
branch = os.environ.get('TRAVIS_BRANCH', 'manual')
pull_request = os.environ.get('TRAVIS_PULL_REQUEST', 'false')
self.sauce.jobs.update_job(self.browser.session_id,
self.sauce.jobs.update_job(self.browser.session_id,
build_num=os.environ.get('TRAVIS_BUILD_NUMBER', '0'),
name='pdf2htmlEX',
passed=passed,
@ -110,7 +110,7 @@ class test_remote_browser_base(BrowserTests):
raise
pass
def generate_image(self, html_file, png_file, page_must_load=True):
def generate_image(self, html_file, png_file):
self.browser.get(BASEURL + html_file)
try:
WebDriverWait(self.browser, 5).until(expected_conditions.presence_of_element_located((By.ID, 'page-container')))