Page MenuHomec4science

test_platex.py
No OneTemporary

File Metadata

Created
Fri, Apr 26, 19:20

test_platex.py

#!/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import print_function
import unittest
try:
from PythonLatex.latex_structure import LatexStructure
except:
pass
class pLatexTest(unittest.TestCase):
"Unit tests for pLatex"
def setUp(self, ):
pass
def test_latex_parser_beamer(self):
latex_code = r"""
\documentclass[9pt,xcolor=dvipsnames]{beamer}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyvrb}
\begin{python}{header}
from Slides.snippet_helper import Snippet, SnippetCollection
Snippet.default_output='latex'
# Snippet.default_line_numbering=True
\end{python}
\py{Snippet.getLatexStyleDefs()}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{class.tex}
\title{Chapter 4. Pointers}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\maketitle
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{Pointers and the Computer's Memory}
\only<1>{
\py{yop}
}
\only<2>{
}
$p_x$
ROW\_MAJOR
\end{frame}
\end{document}
"""
tex_struct = LatexStructure()
tex_struct.parseLatex(latex_code)
output = str(tex_struct)
self.assertEqual(latex_code, output)
def test_latex_parser_nested_begin_end(self):
latex_code = r'''
\begin{toto}tatie
\begin{re}tututoto \end{re} aa\end{toto}
'''
tex_struct = LatexStructure()
tex_struct.parseLatex(latex_code)
output = str(tex_struct)
self.assertEqual(latex_code, output)
def test_latex_parser_begin_end(self):
latex_code = r'\begin{toto}tatie\end{toto}'
tex_struct = LatexStructure()
tex_struct.parseLatex(latex_code)
output = str(tex_struct)
self.assertEqual(latex_code, output)
def test_latex_parser_text(self):
latex_code = r'tatie'
tex_struct = LatexStructure()
tex_struct.parseLatex(latex_code)
output = str(tex_struct)
self.assertEqual(latex_code, output)
def test_latex_parser_command(self):
latex_code = r'\documentclass[10pt]{article}'
tex_struct = LatexStructure()
tex_struct.parseLatex(latex_code)
output = str(tex_struct)
self.assertEqual(latex_code, output)
def test_latex_parser_nested_begin_command(self):
latex_code = r'''{ yala {toto} \begin{align} tutu
\begin{equation} toto \end{equation}
\end{align} {\titi{ tutu} } }'''
tex_struct = LatexStructure()
tex_struct.parseLatex(latex_code)
output = str(tex_struct)
self.assertEqual(latex_code, output)

Event Timeline