Exemplo n.º 1
0
def test_extract_pdf_pages():
    if latex_tools.no_latex():
        warnings.warn("No "+latex_tools.LATEX_EXE+": Tests involving running LaTeX will not be return")
        return
    if os.path.exists(EXTRACT_PDF):
        os.unlink(EXTRACT_PDF)
    assert not os.path.exists(EXTRACT_PDF)
    assert os.path.exists(FIVEPAGES_PDF)
    if os.path.exists(EXTRACT_PDF):
        os.unlink(EXTRACT_PDF)
    try:
        latex_tools.extract_pdf_pages(EXTRACT_PDF,FIVEPAGES_PDF,pagelist=[1])
    except latex_tools.LatexException as e:
        warnings.warn("LatexException: "+str(e))
        return

    assert os.path.exists(EXTRACT_PDF)
    assert os.path.exists(FIVEPAGES_PDF)

    # Make sure precisely one page was extracted
    count = latex_tools.count_pdf_pages(EXTRACT_PDF)
    if count!=1:
        raise RuntimeError("{} does not have {} pages; it has {}".format(
            EXTRACT_PDF,1,count))

    # Finally, delete the extracted file
    os.unlink(EXTRACT_PDF)
Exemplo n.º 2
0
def test_inspect_pdf():
    if latex_tools.no_latex():
        warnings.warn("No "+latex_tools.LATEX_EXE+": Tests involving running LaTeX will not be return")
        return
    try:
        assert latex_tools.count_pdf_pages(FIVEPAGES_PDF) == 5
    except ModuleNotFoundError as e:
        warnings.warn("Module not found: "+str(e))
    except latex_tools.LatexException as e:
        warnings.warn("LatexException: "+str(e))
Exemplo n.º 3
0
def test_count_pdf_pages():
    assert os.path.exists(FIVEPAGES_PDF)  # we need this file
    assert not os.path.exists(FIVEPAGES_AUX)  # we do not want this
    assert not os.path.exists(FIVEPAGES_OUT)  # we do not want this

    pages = latex_tools.count_pdf_pages(FIVEPAGES_PDF)
    assert pages == 5

    assert os.path.exists(FIVEPAGES_PDF)  # make sure file is still there
    assert not os.path.exists(FIVEPAGES_AUX)  # we do not want this
    assert not os.path.exists(FIVEPAGES_OUT)  # we do not want this
Exemplo n.º 4
0
def test_count_pdf_pages():
    if no_latex():
        warnings.warn("No " + latex_tools.LATEX_EXE +
                      ": Tests involving running LaTeX will not be return")
        return
    assert os.path.exists(FIVEPAGES_PDF)  # we need this file
    assert not os.path.exists(FIVEPAGES_AUX)  # we do not want this
    assert not os.path.exists(FIVEPAGES_OUT)  # we do not want this

    pages = latex_tools.count_pdf_pages(FIVEPAGES_PDF)
    assert pages == 5

    assert os.path.exists(FIVEPAGES_PDF)  # make sure file is still there
    assert not os.path.exists(FIVEPAGES_AUX)  # we do not want this
    assert not os.path.exists(FIVEPAGES_OUT)  # we do not want this
Exemplo n.º 5
0
def test_extract_pdf_pages():
    if os.path.exists(EXTRACT_PDF):
        os.unlink(EXTRACT_PDF)
    assert not os.path.exists(EXTRACT_PDF)
    assert os.path.exists(FIVEPAGES_PDF)
    if os.path.exists(EXTRACT_PDF):
        os.unlink(EXTRACT_PDF)
    latex_tools.extract_pdf_pages(EXTRACT_PDF, FIVEPAGES_PDF, pagelist=[1])
    assert os.path.exists(EXTRACT_PDF)
    assert os.path.exists(FIVEPAGES_PDF)

    # Make sure precisely one page was extracted
    count = latex_tools.count_pdf_pages(EXTRACT_PDF)
    if count != 1:
        raise RuntimeError("{} does not have {} pages; it has {}".format(
            EXTRACT_PDF, 1, count))

    # Finally, delete the extracted file
    os.unlink(EXTRACT_PDF)
Exemplo n.º 6
0
def test_inspect_pdf():
    if no_latex():
        warnings.warn("No " + latex_tools.LATEX_EXE +
                      ": Tests involving running LaTeX will not be return")
        return
    assert latex_tools.count_pdf_pages(FIVEPAGES_PDF) == 5
Exemplo n.º 7
0
def test_inspect_pdf():
    assert latex_tools.count_pdf_pages(FIVEPAGES_PDF) == 5