Skip to content

Commit

Permalink
Merge pull request #362 from ChristopherBradley/markdown
Browse files Browse the repository at this point in the history
TST: added test exercising the table markdown method, fixes #351
  • Loading branch information
GavinHuttley committed Nov 8, 2019
2 parents 20531b2 + 053c98b commit 07d6539
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/test_util/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,21 @@ def test_joined(self):
t2.joined(t3, inner_join=False).shape[1], t2.shape[1] + t3.shape[1]
)

def test_markdown(self):
"""Exercising the table markdown method"""
from cogent3.format.table import markdown

t6_header = ["id", "foo", "bar"]
t6_rows = [["60", " | ", "666"], ["70", "bca", "777"]]
markdown_table = markdown(t6_header, t6_rows, justify="crl")
markdown_list = markdown_table.split("\n")
self.assertEqual(markdown_list[2].count(r"|"), 5)
# the pipe symbol should have been escaped
self.assertEqual(markdown_list[2].count(r"\|"), 1)

with self.assertRaises(ValueError):
_ = markdown(t6_header, t6_rows, justify="cr1")

def test_normalized(self):
"""test the table normalized method"""
t5 = Table(header=self.t5_header, rows=self.t5_rows)
Expand Down Expand Up @@ -318,7 +333,7 @@ def test_separator_format(self):
separated_table = separator_format(
t6_header, t6_rows, sep=" | ", title="Test", legend="Units"
)
self.assertEqual(len(separated_table.split("\n")), len(t6_rows)+3)
self.assertEqual(len(separated_table.split("\n")), len(t6_rows) + 3)

def test_separator_format_writer(self):
"""exercising separator_format_writer"""
Expand Down

0 comments on commit 07d6539

Please sign in to comment.