def assert_expected_output(self): if self.expected_output is None: raise NotImplementedError('expected_output is not defined') if not self.run_expected_output: return # Create the xml tree = self.get_xml() # Verify the final output. export_class = self.parser exporter = export_class( document_xml=tree, relationships=self.relationships, numbering_dict=self.numbering_dict, styles_xml=self.styles_xml, ) html = exporter.export() if self.use_base_html: assert_html_equal( html, BASE_HTML % self.expected_output, filename=self.__class__.__name__, ) else: assert_html_equal( html, self.expected_output, filename=self.__class__.__name__, )
def test_convert_to_html_result(self): fixture_html = open("tests/fixtures/inline_tags.html").read() expected_html = BASE_HTML % fixture_html with NamedTemporaryFile() as f: result = main(["--html", "tests/fixtures/inline_tags.docx", f.name]) data = open(f.name).read() assert_html_equal(data, expected_html) self.assertEqual(result, 0)
def test_convert_to_html_result(self): fixture_html = open('tests/fixtures/inline_tags.html').read() expected_html = BASE_HTML % fixture_html with NamedTemporaryFile() as f: result = main([ '--html', 'tests/fixtures/inline_tags.docx', f.name, ]) data = open(f.name).read() assert_html_equal(data, expected_html) self.assertEqual(result, 0)
def test_has_image(): file_path = os.path.join( os.path.abspath(os.path.dirname(__file__)), '..', 'fixtures', 'has_image.docx', ) actual_html = convert(file_path) image_data = get_image_data(file_path, 'image1.gif') assert_html_equal(actual_html, BASE_HTML % ''' <p> AAA <img src="data:image/gif;base64,%s" height="55px" width="260px" /> </p> ''' % image_data)
def test_has_image(): file_path = os.path.join( os.path.abspath(os.path.dirname(__file__)), '..', 'fixtures', 'has_image.docx', ) actual_html = convert(file_path) image_data = get_image_data(file_path, 'image1.gif') expected_html = BASE_HTML % ''' <p> AAA <img height="55px" src="data:image/gif;base64,{data}" width="260px" /> </p> '''.format(data=image_data) assert_html_equal(actual_html, expected_html)
def test_has_image(): file_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "fixtures", "has_image.docx") actual_html = convert(file_path) image_data = get_image_data(file_path, "image1.gif") expected_html = ( BASE_HTML % """ <p> AAA <img height="55px" src="data:image/gif;base64,{data}" width="260px" /> </p> """.format( data=image_data ) ) assert_html_equal(actual_html, expected_html)