Skip to content

Commit

Permalink
Table alignment coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Aug 21, 2017
1 parent 17bf031 commit f2f8290
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/zope/structuredtext/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,14 @@ def doc_table(self, paragraph, expr=re.compile(r'\s*\|[-]+\|').match):
left.sort()
right.sort()

valign = "middle"
if topindent == bottomindent:
valign = "middle"
elif topindent < 1:
valign = "top"
elif bottomindent < 1:
valign = "bottom"
else:
valign = "middle"


if left[0] < 1:
align = "left"
Expand Down
34 changes: 34 additions & 0 deletions src/zope/structuredtext/regressions/table.ref
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,39 @@
</td>
</tr>
</table>
<table border="1" cellpadding="2">
<tr>
<td colspan="1" align="left" valign="middle"><p> Column 1 </p>
</td>
<td colspan="1" align="left" valign="middle"><p> Column </p>
</td>
</tr>
<tr>
<td colspan="1" align="left" valign="top"><p> Align Top </p>
</td>
<td colspan="2" align="center" valign="top"><p> OK </p>
</td>
</tr>
<tr>
<td colspan="1" align="left" valign="bottom"><p> Align Bot </p>
</td>
<td colspan="2" align="center" valign="bottom"><p> OK </p>
</td>
</tr>
<tr>
<td colspan="1" align="left" valign="middle"><p> Align Mid
Note the </p>
</td>
<td colspan="2" align="center" valign="middle"><p> OK
offset unequal. </p>
</td>
</tr>
<tr>
<td colspan="1" align="left" valign="middle"><p>Align left </p>
</td>
<td colspan="2" align="right" valign="middle"><p> Align Right</p>
</td>
</tr>
</table>
</body>
</html>
16 changes: 16 additions & 0 deletions src/zope/structuredtext/regressions/table.stx
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,19 @@
| Col 1 | Col 2 |
|---------------------------------------|

|---------------------------------------|
| Column 1 | Column 2
|---------------------------------------|
| Align Top | OK |
| | |
|---------------------------------------|
| | |
| Align Bot | OK |
|---------------------------------------|
| | |
| Align Mid | OK |
| Note the | offset unequal. |
| | |
|---------------------------------------|
|Align left | Align Right|
|---------------------------------------|
2 changes: 1 addition & 1 deletion src/zope/structuredtext/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _compare(self, filename, output, expected_extension=".ref"):
with open(full_expected_fname, 'w') as f:
f.write(output)
else:
self.assertEqual(output.strip(), expected.strip())
self.assertEqual(expected.strip(), output.strip())

def _check_html(self, f):
# HTML regression test
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ deps =
[testenv:coverage]
usedevelop = true
basepython =
python2.7
python3.6
commands =
coverage run -m zope.testrunner --test-path=src
coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest
Expand Down

0 comments on commit f2f8290

Please sign in to comment.