Skip to content

Commit

Permalink
Added support for empty pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikfo committed Jan 21, 2025
1 parent 974a168 commit 2580264
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions leakpro/reporting/report_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ def _init_pdf(self:Self) -> None:
def _compile_pdf(self:Self) -> None:
"""Method to compile PDF."""

# Support for an empty pdf to compile
if self.latex_content.strip()[-16:] == "\\begin{document}":
self.latex_content += "\\null"
self.logger.info("Warning! You are about to compile an empty pdf.")
self.logger.info("Please ensure that you append your results!")

self.latex_content += """
\\end{document}
"""
Expand Down
10 changes: 8 additions & 2 deletions leakpro/tests/test_report_handler/test_report_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def test_compile_pdf(self:Self) -> None:
assert os.path.isfile(f"{self.report_handler.report_dir}/LeakPro_output.pdf")

def test_create_pdf(self:Self) -> None:

report_handler = ReportHandler(report_dir=self.temp_dir.name, logger=self.logger)

# Load results
Expand All @@ -68,4 +67,11 @@ def test_create_pdf(self:Self) -> None:
report_handler.create_report()

assert os.path.isfile(f"{self.report_handler.report_dir}/LeakPro_output.pdf")


def test_create_empty_pdf(self:Self) -> None:
report_handler = ReportHandler(report_dir=self.temp_dir.name, logger=self.logger)

report_handler._init_pdf()
report_handler._compile_pdf()

assert os.path.isfile(f"{self.report_handler.report_dir}/LeakPro_output.pdf")

0 comments on commit 2580264

Please sign in to comment.