From 7a47e70a7c8a56c206b44c051f760d2bd7cc5637 Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio Date: Tue, 23 Jul 2024 23:45:42 +0200 Subject: [PATCH] Make test pytest compatible --- MANIFEST.in | 1 + tests/test_tabular.py | 18 +++++------------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index f257d1b3..7852f404 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,3 +3,4 @@ recursive-include pylatex *.py recursive-include python2_source/pylatex *.py include versioneer.py include examples/kitten.jpg +include examples/sample-logo.png diff --git a/tests/test_tabular.py b/tests/test_tabular.py index de4b0652..69086049 100644 --- a/tests/test_tabular.py +++ b/tests/test_tabular.py @@ -1,11 +1,12 @@ #!/usr/bin/env python +import os.path as osp from pylatex import Document, MultiColumn, Section, StandAloneGraphic, Tabular # This file contains function that test several Tabular related functionality. -def test_tabular_can_add_row_passing_many_arguments(sample_logo_path): +def test_tabular_can_add_row_passing_many_arguments(): """ Test that Tabular can add a row as described in the function body: The first method is to pass the content of each cell as a separate argument. @@ -16,6 +17,7 @@ def test_tabular_can_add_row_passing_many_arguments(sample_logo_path): """ doc = Document() + sample_logo_path = osp.join(__file__[0:-15], "..", "examples", "sample-logo.png") with doc.create(Section("Can Add Row Passing Many Arguments")): with doc.create(Tabular("|c|c|", booktabs=True)) as table: @@ -30,7 +32,7 @@ def test_tabular_can_add_row_passing_many_arguments(sample_logo_path): doc.generate_pdf(clean_tex=False) -def test_tabular_can_add_row_passing_iterable(sample_logo_path): +def test_tabular_can_add_row_passing_iterable(): """ Test that Tabular can add a row as described in the function body: The second method @@ -44,6 +46,7 @@ def test_tabular_can_add_row_passing_iterable(sample_logo_path): """ doc = Document() + sample_logo_path = osp.join(__file__[0:-15], "..", "examples", "sample-logo.png") with doc.create(Section("Can Add Row Passing Iterable")): with doc.create(Tabular("|c|c|", booktabs=True)) as table: multi_columns_array = [ @@ -57,14 +60,3 @@ def test_tabular_can_add_row_passing_iterable(sample_logo_path): table.add_row(multi_columns_array) doc.generate_pdf() - - -if __name__ == "__main__": - import os.path as osp - - sample_logo_path = osp.abspath( - osp.join(__file__[0:-15], "..", "examples", "sample-logo.png") - ) - - test_tabular_can_add_row_passing_many_arguments(sample_logo_path=sample_logo_path) - test_tabular_can_add_row_passing_iterable(sample_logo_path=sample_logo_path)