@@ -11,6 +11,9 @@ def setUp(self) -> None:
1111 """\\ documentclass{article}\\ begin{document}\\ end{document}"""
1212 )
1313 self .mock_file_content2 = """\\ documentclass{article}\\ begin{document}Table \\ ref{demo-table} has a caption:\\ begin{table}[!h]\\ begin{center}\\ begin{tabular}{||c c c c||} \\ hline Col1 & Col2 & Col2 & Col3 \\ [0.5ex] \\ hline\\ hline 1 & 6 & 87837 & 787 \\ \\ hline 2 & 7 & 78 & 5415 \\ \\ hline 3 & 545 & 778 & 7507 \\ \\ hline 4 & 545 & 18744 & 7560 \\ \\ hline 5 & 88 & 788 & 6344 \\ [1ex] \\ hline\\ end{tabular}\\ caption{\\ label{demo-table}Your caption.}\\ end{center}\\ end{table}\\ end{document}"""
14+ self .mock_file_content3 = """\\ documentclass{article}\\ begin{document}Table \\ ref{demo-table} has a caption:\\ begin{table}[!h]\\ begin{center}\\ begin{tabularx}{||c c c c||} \\ hline Col1 & Col2 & Col2 & Col3 \\ [0.5ex] \\ hline\\ hline 1 & 6 & 87837 & 787 \\ \\ hline 2 & 7 & 78 & 5415 \\ \\ hline 3 & 545 & 778 & 7507 \\ \\ hline 4 & 545 & 18744 & 7560 \\ \\ hline 5 & 88 & 788 & 6344 \\ [1ex] \\ hline\\ end{tabularx}\\ caption{\\ label{demo-table}Your caption.}\\ end{center}\\ end{table}\\ end{document}"""
15+ self .mock_file_content4 = """\\ documentclass{article}\\ begin{document}Table \\ ref{demo-table} has a caption:\\ begin{table}[!h]\\ begin{center}\\ begin{tabular}{||c c c c||} \\ hline Col1 & Col2 & Col2 & Col3 \\ [0.5ex] \\ hline\\ hline 1 & 6 & 87837 & 787 \\ \\ hline 2 & 7 & 78 & 5415 \\ \\ hline 3 & 545 & 778 & 7507 \\ \\ hline 4 & 545 & 18744 & 7560 \\ \\ hline 5 & 88 & 788 & 6344 \\ [1ex] \\ hline\\ end{tabular}\\ caption{\\ label{demo-table}Your caption.}\\ end{center}\\ end{table} \\ begin{table}[!h]\\ begin{center}\\ begin{tabularx}{||c c c c||} \\ hline Col1 & Col2 & Col2 & Col3 \\ [0.5ex] \\ hline\\ hline 1 & 6 & 87837 & 787 \\ \\ hline 2 & 7 & 78 & 5415 \\ \\ hline 3 & 545 & 778 & 7507 \\ \\ hline 4 & 545 & 18744 & 7560 \\ \\ hline 5 & 88 & 788 & 6344 \\ [1ex] \\ hline\\ end{tabularx}\\ caption{\\ label{demo-table}Your caption.}\\ end{center}\\ end{table}\\ end{document}"""
16+
1417 self .renderer = Renderer ()
1518
1619 def test_no_tabular (self ):
@@ -36,3 +39,27 @@ def test_one_tabular(self):
3639 file_mock ().write .assert_called_with (
3740 """\\ documentclass{article}\\ begin{document}Table \\ ref{demo-table} has a caption:\\ begin{table}[!h]\\ begin{center}{\\ color{Table_color}\\ begin{tabular}{||c c c c||} \\ hline Col1 & Col2 & Col2 & Col3 \\ [0.5ex] \\ hline\\ hline 1 & 6 & 87837 & 787 \\ \\ hline 2 & 7 & 78 & 5415 \\ \\ hline 3 & 545 & 778 & 7507 \\ \\ hline 4 & 545 & 18744 & 7560 \\ \\ hline 5 & 88 & 788 & 6344 \\ [1ex] \\ hline\\ end{tabular}}\\ caption{\\ label{demo-table}Your caption.}\\ end{center}\\ end{table}\\ end{document}"""
3841 )
42+
43+ def test_one_tabularx (self ):
44+ with unittest .mock .patch (
45+ "builtins.open" ,
46+ new = unittest .mock .mock_open (read_data = self .mock_file_content3 ),
47+ create = True ,
48+ ) as file_mock :
49+ self .renderer .render_tabular (file_mock )
50+ file_mock .assert_called_with (file_mock , "w" )
51+ file_mock ().write .assert_called_with (
52+ """\\ documentclass{article}\\ begin{document}Table \\ ref{demo-table} has a caption:\\ begin{table}[!h]\\ begin{center}{\\ color{Table_color}\\ begin{tabularx}{||c c c c||} \\ hline Col1 & Col2 & Col2 & Col3 \\ [0.5ex] \\ hline\\ hline 1 & 6 & 87837 & 787 \\ \\ hline 2 & 7 & 78 & 5415 \\ \\ hline 3 & 545 & 778 & 7507 \\ \\ hline 4 & 545 & 18744 & 7560 \\ \\ hline 5 & 88 & 788 & 6344 \\ [1ex] \\ hline\\ end{tabularx}}\\ caption{\\ label{demo-table}Your caption.}\\ end{center}\\ end{table}\\ end{document}"""
53+ )
54+
55+ def test_mix_tabulars (self ):
56+ with unittest .mock .patch (
57+ "builtins.open" ,
58+ new = unittest .mock .mock_open (read_data = self .mock_file_content4 ),
59+ create = True ,
60+ ) as file_mock :
61+ self .renderer .render_tabular (file_mock )
62+ file_mock .assert_called_with (file_mock , "w" )
63+ file_mock ().write .assert_called_with (
64+ """\\ documentclass{article}\\ begin{document}Table \\ ref{demo-table} has a caption:\\ begin{table}[!h]\\ begin{center}{\\ color{Table_color}\\ begin{tabular}{||c c c c||} \\ hline Col1 & Col2 & Col2 & Col3 \\ [0.5ex] \\ hline\\ hline 1 & 6 & 87837 & 787 \\ \\ hline 2 & 7 & 78 & 5415 \\ \\ hline 3 & 545 & 778 & 7507 \\ \\ hline 4 & 545 & 18744 & 7560 \\ \\ hline 5 & 88 & 788 & 6344 \\ [1ex] \\ hline\\ end{tabular}}\\ caption{\\ label{demo-table}Your caption.}\\ end{center}\\ end{table} \\ begin{table}[!h]\\ begin{center}{\\ color{Table_color}\\ begin{tabularx}{||c c c c||} \\ hline Col1 & Col2 & Col2 & Col3 \\ [0.5ex] \\ hline\\ hline 1 & 6 & 87837 & 787 \\ \\ hline 2 & 7 & 78 & 5415 \\ \\ hline 3 & 545 & 778 & 7507 \\ \\ hline 4 & 545 & 18744 & 7560 \\ \\ hline 5 & 88 & 788 & 6344 \\ [1ex] \\ hline\\ end{tabularx}}\\ caption{\\ label{demo-table}Your caption.}\\ end{center}\\ end{table}\\ end{document}"""
65+ )
0 commit comments