-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
1,650 additions
and
1,610 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ dependencies: | |
- click | ||
- furo | ||
- numpy | ||
- pytest | ||
- python | ||
- setuptools_scm | ||
- sphinx | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,109 +1,102 @@ | ||
import unittest | ||
|
||
import texplain | ||
|
||
|
||
class TestAlignTabular(unittest.TestCase): | ||
""" | ||
Alignment of tabular environments. | ||
""" | ||
|
||
def test_align_no_newline(self): | ||
text = r""" | ||
def test_tabular_align_no_newline(): | ||
text = r""" | ||
\begin{tabular}{ccc} | ||
a & b & c \\ | ||
1 & 2 & 3 \\ | ||
40 & 50 & 60 | ||
\end{tabular} | ||
""" | ||
""" | ||
|
||
formatted = r""" | ||
formatted = r""" | ||
\begin{tabular}{ccc} | ||
a & b & c \\ | ||
1 & 2 & 3 \\ | ||
40 & 50 & 60 | ||
\end{tabular} | ||
""" | ||
""" | ||
|
||
ret = texplain.indent(text) | ||
self.assertEqual(ret.strip(), formatted.strip()) | ||
ret = texplain.indent(text) | ||
assert ret.strip() == formatted.strip() | ||
|
||
def test_align_empty(self): | ||
text = r""" | ||
|
||
def test_tabular_align_empty(): | ||
text = r""" | ||
\begin{tabular}[t]{c}% | ||
\@author | ||
\end{tabular} | ||
""" | ||
""" | ||
|
||
formatted = r""" | ||
formatted = r""" | ||
\begin{tabular}[t]{c}% | ||
\@author | ||
\end{tabular} | ||
""" | ||
""" | ||
|
||
ret = texplain.indent(text) | ||
assert ret.strip() == formatted.strip() | ||
|
||
ret = texplain.indent(text) | ||
self.assertEqual(ret.strip(), formatted.strip()) | ||
|
||
def test_align_nested(self): | ||
text = r""" | ||
def test_tabular_align_nested(): | ||
text = r""" | ||
{ | ||
\begin{tabular}[t]{c}% | ||
\@author % foo | ||
\end{tabular} | ||
} | ||
""" | ||
""" | ||
|
||
formatted = r""" | ||
formatted = r""" | ||
{ | ||
\begin{tabular}[t]{c}% | ||
\@author % foo | ||
\end{tabular} | ||
} | ||
""" | ||
""" | ||
|
||
ret = texplain.indent(text) | ||
self.assertEqual(ret.strip(), formatted.strip()) | ||
ret = texplain.indent(text) | ||
assert ret.strip() == formatted.strip() | ||
|
||
def test_align_empty_leading_column(self): | ||
text = r""" | ||
|
||
def test_tabular_align_empty_leading_column(): | ||
text = r""" | ||
\begin{tabular}[t]{ccc} | ||
& foo & foobar \\ | ||
1 & 2 & 3 \\ | ||
4 & 5 & 6 | ||
\end{tabular} | ||
""" | ||
""" | ||
|
||
formatted = r""" | ||
formatted = r""" | ||
\begin{tabular}[t]{ccc} | ||
& foo & foobar \\ | ||
1 & 2 & 3 \\ | ||
4 & 5 & 6 | ||
\end{tabular} | ||
""" | ||
""" | ||
|
||
ret = texplain.indent(text) | ||
assert ret.strip() == formatted.strip() | ||
|
||
ret = texplain.indent(text) | ||
self.assertEqual(ret.strip(), formatted.strip()) | ||
|
||
def test_align_empty_column(self): | ||
text = r""" | ||
def test_tabular_align_empty_column(): | ||
text = r""" | ||
\begin{tabular}[t]{ccc} | ||
& foo & foobar \\ | ||
& 2 & 3 \\ | ||
& 5 & 6 | ||
\end{tabular} | ||
""" | ||
""" | ||
|
||
formatted = r""" | ||
formatted = r""" | ||
\begin{tabular}[t]{ccc} | ||
& foo & foobar \\ | ||
& 2 & 3 \\ | ||
& 5 & 6 | ||
\end{tabular} | ||
""" | ||
|
||
ret = texplain.indent(text) | ||
self.assertEqual(ret.strip(), formatted.strip()) | ||
|
||
""" | ||
|
||
if __name__ == "__main__": | ||
unittest.main() | ||
ret = texplain.indent(text) | ||
assert ret.strip() == formatted.strip() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
import unittest | ||
|
||
import texplain | ||
|
||
|
||
class MyTests(unittest.TestCase): | ||
def test_bib(self): | ||
bib = { | ||
"foo": ["@article{foo,", "author = {b a},", "title = {b a},", "journal = {b a},", "}"], | ||
"bar": ["@article{bar,", "author = {a b},", "title = {a b},", "journal = {a b},", "}"], | ||
} | ||
|
||
bibfile = "\n\n".join(["\n".join(bib[key]) for key in ["foo", "bar"]]) | ||
self.assertEqual(texplain.bib_select(bibfile, ["bar", "foo"]).strip(), bibfile.strip()) | ||
|
||
bibfile = "\n\n".join(["\n".join(bib[key]) for key in ["foo", "bar"]]) | ||
reduced = "\n\n".join(["\n".join(bib[key]) for key in ["bar"]]) | ||
self.assertEqual(texplain.bib_select(bibfile, ["bar"]).strip(), reduced.strip()) | ||
def test_bib(): | ||
bib = { | ||
"foo": ["@article{foo,", "author = {b a},", "title = {b a},", "journal = {b a},", "}"], | ||
"bar": ["@article{bar,", "author = {a b},", "title = {a b},", "journal = {a b},", "}"], | ||
} | ||
|
||
bibfile = "\n\n".join(["\n".join(bib[key]) for key in ["foo", "bar"]]) | ||
reorder = "\n\n".join(["\n".join(bib[key]) for key in ["bar", "foo"]]) | ||
self.assertEqual( | ||
texplain.bib_select(bibfile, ["bar", "foo"], reorder=True).strip(), reorder.strip() | ||
) | ||
bibfile = "\n\n".join(["\n".join(bib[key]) for key in ["foo", "bar"]]) | ||
assert texplain.bib_select(bibfile, ["bar", "foo"]).strip() == bibfile.strip() | ||
|
||
bibfile = "\n\n".join(["\n".join(bib[key]) for key in ["foo", "bar"]]) | ||
reduced = "\n\n".join(["\n".join(bib[key]) for key in ["bar"]]) | ||
assert texplain.bib_select(bibfile, ["bar"]).strip() == reduced.strip() | ||
|
||
if __name__ == "__main__": | ||
unittest.main() | ||
bibfile = "\n\n".join(["\n".join(bib[key]) for key in ["foo", "bar"]]) | ||
reorder = "\n\n".join(["\n".join(bib[key]) for key in ["bar", "foo"]]) | ||
assert texplain.bib_select(bibfile, ["bar", "foo"], reorder=True).strip() == reorder.strip() |
Oops, something went wrong.