Skip to content

Commit

Permalink
Run black on merged PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Jul 23, 2024
1 parent edef12c commit 92d394b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 33 deletions.
2 changes: 1 addition & 1 deletion pylatex/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def flatten(x):
return [a for i in x for a in flatten(i)]
else:
return [x]

flat_list = [c for c in cells] + flatten(cells)
for c in flat_list:
if isinstance(c, LatexObject):
Expand Down
67 changes: 35 additions & 32 deletions tests/test_tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

# This file contains function that test several Tabular related functionality.


def test_tabular_can_add_row_passing_many_arguments(sample_logo_path):
"""
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.
The first method is to pass the content of each cell as a separate argument.
Returns
-------
Expand All @@ -16,25 +17,26 @@ def test_tabular_can_add_row_passing_many_arguments(sample_logo_path):
"""
doc = Document()

with doc.create(Section('Can Add Row Passing Many Arguments')):
with doc.create(Tabular("|c|c|", booktabs=True)) as table:

mc1 = MultiColumn(1, align='l', data=StandAloneGraphic(
filename=sample_logo_path))
mc2 = MultiColumn(1, align='l', data=StandAloneGraphic(
filename=sample_logo_path))
with doc.create(Section("Can Add Row Passing Many Arguments")):
with doc.create(Tabular("|c|c|", booktabs=True)) as table:

mc1 = MultiColumn(
1, align="l", data=StandAloneGraphic(filename=sample_logo_path)
)
mc2 = MultiColumn(
1, align="l", data=StandAloneGraphic(filename=sample_logo_path)
)


table.add_row(mc1, mc2)
doc.generate_pdf(clean_tex=False)


def test_tabular_can_add_row_passing_iterable(sample_logo_path):
"""
Test that Tabular can add a row as described in the function body:
The second method
is to pass a single argument that is an iterable that contains each
contents.
contents.
Returns
-------
Expand All @@ -43,27 +45,28 @@ def test_tabular_can_add_row_passing_iterable(sample_logo_path):
"""
doc = Document()

with doc.create(Section('Can Add Row Passing Iterable')):
with doc.create(Tabular("|c|c|", booktabs=True)) as table:
multi_columns_array = [
MultiColumn(1, align='l', data=StandAloneGraphic(
filename=sample_logo_path)),
MultiColumn(1, align='l', data=StandAloneGraphic(
filename=sample_logo_path))
]

table.add_row(multi_columns_array)
with doc.create(Section("Can Add Row Passing Iterable")):
with doc.create(Tabular("|c|c|", booktabs=True)) as table:
multi_columns_array = [
MultiColumn(
1, align="l", data=StandAloneGraphic(filename=sample_logo_path)
),
MultiColumn(
1, align="l", data=StandAloneGraphic(filename=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)

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)

0 comments on commit 92d394b

Please sign in to comment.