Example #1
0
def compare_doc(doc: DocumentBase, name: str):
    if GENERATE_MODE:
        return doc.to_pdf(INPUT_FILES_DIR, outname=name)

    compare_path = INPUT_FILES_DIR / f"{name}.tex"
    assert str(doc) == compare_path.read_text()
    doc.to_pdf(GENERATED_FILES_DIR, outname=name)
    compare_pdfs(INPUT_FILES_DIR / f'{name}.pdf',
                 GENERATED_FILES_DIR / f'{name}.pdf')
def test_package_conflict():
    section = pl.Section(['woo'], title='Section')
    section.init_data()
    section.add_package(pl.Package('hyperref', modifier_str='hidelinks'))
    # Without eq_on_modifier=False, raises error for package options conflict
    section.add_package(
        pl.Package('hyperref',
                   modifier_str='linktoc=all',
                   eq_on_modifier=False))
    doc = pl.Document([section])
    doc.to_pdf(GENERATED_FILES_DIR, outname='package conflict document')
    compare_pdfs(INPUT_FILES_DIR / 'package conflict document.pdf',
                 GENERATED_FILES_DIR / 'package conflict document.pdf')
Example #3
0
def test_inline_graphic_in_document():
    ig = pl.InlineGraphic(str(EXAMPLE_IMAGE_PATH), width=0.1)
    ig2 = pl.InlineGraphic(str(EXAMPLE_IMAGE_PATH), width=0.1)
    contents = [
        'Some inline text before', ig,
        'and after and then wrapping onto the next line so that '
        'I can make sure that it is working properly in the case '
        'that it is used in a real document', ig2
    ]
    doc = pl.Document(contents)
    assert EXPECT_DEFINITION in str(doc)
    assert EXPECT_GRAPHIC in str(doc)
    doc.to_pdf(GENERATED_FILES_DIR, outname='inline graphic document')
    compare_pdfs(INPUT_FILES_DIR / 'inline graphic document.pdf',
                 GENERATED_FILES_DIR / 'inline graphic document.pdf')
Example #4
0
 def test_to_pdf_with_references(self):
     doc = Document(['woo', self.citation, self.bibliography])
     doc.to_pdf(GENERATED_FILES_DIR, outname='document with references')
     compare_pdfs(INPUT_FILES_DIR / 'document with references.pdf',
                  GENERATED_FILES_DIR / 'document with references.pdf')
Example #5
0
 def test_to_pdf(self):
     doc = Document('woo')
     doc.to_pdf(GENERATED_FILES_DIR)
     compare_pdfs(INPUT_FILES_DIR / 'document.pdf',
                  GENERATED_FILES_DIR / 'document.pdf')