Skip to content

Commit

Permalink
Test & document a corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
jwodder committed Jul 23, 2018
1 parent 2ff2196 commit 007ec1b
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ constructor or as attributes on a ``Txtble`` instance::
set to a ``BorderStyle`` instance to set the characters used for drawing the
horizontal rule above the data rows.

If ``headers`` is `None` and ``top_border`` is set to a true value (or
inherits a true value from ``border``), the header border will not be drawn.

``header_fill=None``
When ``headers`` is non-`None` and ``columns`` is `None`, this option
determines how rows with more columns than there are headers are handled.
Expand Down
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- Don't break in the middle of combining character sequences
- Don't break on a space or hyphen followed by combining characters
- Break on more than just spaces and hyphens?
- cf. the Unicode line breaking algorithm
- cf. the Unicode line breaking algorithm and Unicode TR 29
- cf. `uniseg` package

Features to Add
Expand Down
75 changes: 75 additions & 0 deletions test/test_border_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,78 @@ def test_bad_border_style(border_style):
match='border_style must be a BorderStyle instance',
):
str(tbl)

def test_border_vs_header_border_style():
tbl = Txtble(DATA, border=HEAVY_BORDERS, header_border=DOUBLE_BORDERS)
assert text_type(tbl) == (
u'┏━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓\n'
u'┃January |Garnet |Carnation ┃\n'
u'┃February |Amethyst |Violet ┃\n'
u'┃March |Aquamarine|Jonquil ┃\n'
u'┃April |Diamond |Sweetpea ┃\n'
u'┃May |Emerald |Lily Of The Valley┃\n'
u'┃June |Pearl |Rose ┃\n'
u'┃July |Ruby |Larkspur ┃\n'
u'┃August |Peridot |Gladiolus ┃\n'
u'┃September|Sapphire |Aster ┃\n'
u'┃October |Opal |Calendula ┃\n'
u'┃November |Topaz |Chrysanthemum ┃\n'
u'┃December |Turquoise |Narcissus ┃\n'
u'┗━━━━━━━━━┻━━━━━━━━━━┻━━━━━━━━━━━━━━━━━━┛'
)

def test_top_border_vs_header_border_style():
tbl = Txtble(DATA, top_border=HEAVY_BORDERS, header_border=DOUBLE_BORDERS)
assert text_type(tbl) == (
u'┏━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┓\n'
u'|January |Garnet |Carnation |\n'
u'|February |Amethyst |Violet |\n'
u'|March |Aquamarine|Jonquil |\n'
u'|April |Diamond |Sweetpea |\n'
u'|May |Emerald |Lily Of The Valley|\n'
u'|June |Pearl |Rose |\n'
u'|July |Ruby |Larkspur |\n'
u'|August |Peridot |Gladiolus |\n'
u'|September|Sapphire |Aster |\n'
u'|October |Opal |Calendula |\n'
u'|November |Topaz |Chrysanthemum |\n'
u'|December |Turquoise |Narcissus |\n'
u'+---------+----------+------------------+'
)

def test_no_border_header_border_style():
tbl = Txtble(DATA, border=False, header_border=DOUBLE_BORDERS)
assert text_type(tbl) == (
u'═════════╦══════════╦══════════════════\n'
u'January |Garnet |Carnation\n'
u'February |Amethyst |Violet\n'
u'March |Aquamarine|Jonquil\n'
u'April |Diamond |Sweetpea\n'
u'May |Emerald |Lily Of The Valley\n'
u'June |Pearl |Rose\n'
u'July |Ruby |Larkspur\n'
u'August |Peridot |Gladiolus\n'
u'September|Sapphire |Aster\n'
u'October |Opal |Calendula\n'
u'November |Topaz |Chrysanthemum\n'
u'December |Turquoise |Narcissus'
)

def test_no_top_border_header_border_style():
tbl = Txtble(DATA, top_border=False, header_border=DOUBLE_BORDERS)
assert text_type(tbl) == (
u'╔═════════╦══════════╦══════════════════╗\n'
u'|January |Garnet |Carnation |\n'
u'|February |Amethyst |Violet |\n'
u'|March |Aquamarine|Jonquil |\n'
u'|April |Diamond |Sweetpea |\n'
u'|May |Emerald |Lily Of The Valley|\n'
u'|June |Pearl |Rose |\n'
u'|July |Ruby |Larkspur |\n'
u'|August |Peridot |Gladiolus |\n'
u'|September|Sapphire |Aster |\n'
u'|October |Opal |Calendula |\n'
u'|November |Topaz |Chrysanthemum |\n'
u'|December |Turquoise |Narcissus |\n'
u'+---------+----------+------------------+'
)

0 comments on commit 007ec1b

Please sign in to comment.