mirror of https://github.com/eyhc1/rendercv.git
fix tests
This commit is contained in:
parent
05930e0d80
commit
fdd95d9c88
|
@ -444,19 +444,16 @@ def run_latex(latex_file_path: str) -> str:
|
||||||
)
|
)
|
||||||
|
|
||||||
# Run TinyTeX:
|
# Run TinyTeX:
|
||||||
|
def run():
|
||||||
with subprocess.Popen(
|
with subprocess.Popen(
|
||||||
[
|
[
|
||||||
executable,
|
executable,
|
||||||
f"{latex_file_name}",
|
f"{latex_file_name}",
|
||||||
"&&",
|
|
||||||
executable,
|
|
||||||
f"{latex_file_name}",
|
|
||||||
],
|
],
|
||||||
cwd=os.path.dirname(latex_file_path),
|
cwd=os.path.dirname(latex_file_path),
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stdin=subprocess.DEVNULL, # don't allow TinyTeX to ask for user input
|
stdin=subprocess.DEVNULL, # don't allow TinyTeX to ask for user input
|
||||||
text=True,
|
text=True,
|
||||||
shell=True,
|
|
||||||
) as latex_process:
|
) as latex_process:
|
||||||
output, error = latex_process.communicate()
|
output, error = latex_process.communicate()
|
||||||
|
|
||||||
|
@ -474,6 +471,9 @@ def run_latex(latex_file_path: str) -> str:
|
||||||
" or open an issue on GitHub.",
|
" or open an issue on GitHub.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
run()
|
||||||
|
run() # run twice for cross-references
|
||||||
|
|
||||||
# check if the PDF file is generated:
|
# check if the PDF file is generated:
|
||||||
if not os.path.exists(output_file_path):
|
if not os.path.exists(output_file_path):
|
||||||
raise FileNotFoundError(
|
raise FileNotFoundError(
|
||||||
|
|
|
@ -12,6 +12,7 @@ class TestCLI(unittest.TestCase):
|
||||||
# Change the working directory to the root of the project:
|
# Change the working directory to the root of the project:
|
||||||
workspace_path = os.path.dirname(os.path.dirname(__file__))
|
workspace_path = os.path.dirname(os.path.dirname(__file__))
|
||||||
|
|
||||||
|
with self.subTest(msg="Correct input"):
|
||||||
test_input_file_path = os.path.join(
|
test_input_file_path = os.path.join(
|
||||||
workspace_path,
|
workspace_path,
|
||||||
"tests",
|
"tests",
|
||||||
|
@ -34,7 +35,10 @@ class TestCLI(unittest.TestCase):
|
||||||
|
|
||||||
# Compare the pdf file with the reference pdf file:
|
# Compare the pdf file with the reference pdf file:
|
||||||
reference_pdf_file = os.path.join(
|
reference_pdf_file = os.path.join(
|
||||||
workspace_path, "tests", "reference_files", "John_Doe_CV_pdf_reference.pdf"
|
workspace_path,
|
||||||
|
"tests",
|
||||||
|
"reference_files",
|
||||||
|
"John_Doe_CV_pdf_reference.pdf",
|
||||||
)
|
)
|
||||||
reference_pdf_file_size = os.path.getsize(reference_pdf_file)
|
reference_pdf_file_size = os.path.getsize(reference_pdf_file)
|
||||||
ratio = min(reference_pdf_file_size, pdf_file_size) / max(
|
ratio = min(reference_pdf_file_size, pdf_file_size) / max(
|
||||||
|
|
Loading…
Reference in New Issue