コード例 #1
0
ファイル: testcases.py プロジェクト: botzill/pydocx
 def assert_document_generates_html(
     self,
     document,
     expected_html,
     additional_parts=None,
     save_zip_on_failure=False,
 ):
     zip_archive = self.get_zip_archive_for_document(
         document,
         additional_parts=additional_parts,
     )
     exporter = self.exporter(zip_archive)
     actual = exporter.export()
     expected = self.format_expected_html(expected_html)
     if not html_is_equal(actual, expected):
         try:
             actual = prettify(actual)
         except ExpatError:
             pass
         message = [
             'The expected HTML did not match the actual HTML:',
             actual,
         ]
         if save_zip_on_failure:
             _, path_to_docx = mkstemp(suffix='.docx', prefix='pydocx-')
             with open(path_to_docx, 'w') as f:
                 zip_archive.seek(0)
                 f.write(zip_archive.read())
             message.append(
                 'The docx was saved to {path}'.format(path=path_to_docx),
             )
         raise AssertionError('\n'.join(message))
コード例 #2
0
 def assert_document_generates_html(
     self,
     document,
     expected_html,
     additional_parts=None,
     save_zip_on_failure=False,
 ):
     zip_archive = self.get_zip_archive_for_document(
         document,
         additional_parts=additional_parts,
     )
     exporter = self.exporter(zip_archive)
     actual = exporter.export()
     expected = self.format_expected_html(expected_html)
     if not html_is_equal(actual, expected):
         try:
             actual = prettify(actual)
         except ExpatError:
             pass
         message = [
             'The expected HTML did not match the actual HTML:',
             actual,
         ]
         if save_zip_on_failure:
             _, path_to_docx = mkstemp(suffix='.docx', prefix='pydocx-')
             with open(path_to_docx, 'w') as f:
                 zip_archive.seek(0)
                 f.write(zip_archive.read())
             message.append(
                 'The docx was saved to {path}'.format(path=path_to_docx), )
         raise AssertionError('\n'.join(message))
コード例 #3
0
ファイル: test_docx.py プロジェクト: OmniaSolutions/pydocx
 def assertHtmlEqual(self, actual, expected):
     if not html_is_equal(actual, expected):
         actual = prettify(actual)
         message = 'The expected HTML did not match the actual HTML:'
         raise AssertionError(message + '\n' + actual)
コード例 #4
0
 def assertHtmlEqual(self, actual, expected):
     if not html_is_equal(actual, expected):
         actual = prettify(actual)
         message = 'The expected HTML did not match the actual HTML:'
         raise AssertionError(message + '\n' + actual)