mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
copy edit
This commit is contained in:
parent
e2b41a9297
commit
7be77ea1b9
@ -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')
|
||||
|
@ -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')))
|
||||
|
Loading…
Reference in New Issue
Block a user