Exemplo n.º 1
0
    def test_cleanup(self):

        printer = PDFPrinter('tests')
        printer.render(self.get_tex_source('tests/sample.tex'))
        printer.cleanup()

        if os.path.isdir(printer.out_dir):
            pytest.fail("Can't remove temporary files.")
Exemplo n.º 2
0
    def test_pdfprinter(self):

        printer = PDFPrinter('tests')

        try:
            printer.render(self.get_tex_source('tests/sample.tex'))
            result = open(printer.out_dir + '/result.pdf')
            result.close()
        except Exception:
            pytest.fail("Input can't be compiled into result.pdf.")
Exemplo n.º 3
0
    def test_error_handling(self):
        printer = PDFPrinter('tests')
        cur_path = os.path.join(os.getcwd(), 'tests')
        printer.out_dir = cur_path

        with pytest.raises(LatexError) as excinfo:
            printer.run_latex(cur_path + '/corrupt_sample.tex')
        assert excinfo.value.message == 'Latex reported no output created'

        os.remove(cur_path + '/corrupt_sample.log')
        os.remove(cur_path + '/corrupt_sample.aux')
Exemplo n.º 4
0
    def test_run_latex(self):
        printer = PDFPrinter('tests')
        cur_path = os.path.join(os.getcwd(), 'tests')
        printer.out_dir = cur_path

        try:
            printer.run_latex(cur_path + '/simple_sample.tex')
            os.remove(cur_path + '/simple_sample.log')
            os.remove(cur_path + '/simple_sample.aux')
            os.remove(cur_path + '/simple_sample.pdf')
        except:
            pytest.fail("Can't compile sample.tex")
Exemplo n.º 5
0
    def test_write_tex_to_file(self):

        printer = PDFPrinter('tests')
        printer.out_dir = 'tests'

        try:
            printer.write_tex_to_file(self.get_tex_source('tests/sample.tex'))
            result = open('tests/result.tex')
            result.close()
            os.remove(os.path.join(os.getcwd(), 'tests/result.tex'))
        except:
            pytest.fail("Can't write_tex_to_file.")
Exemplo n.º 6
0
    def test_prepare_temp_dir(self):
        printer = PDFPrinter('tests')
        printer.prepare_temp_dir()

        assert os.path.exists(printer.out_dir), True