示例#1
0
    def test_simple(self):

        mock_files = {
            # list of files that "exist"
            "mymacros.sty": "%test",
            "cleveref.sty": "%test",
        }
        usepackage.os_path = helpers.FakeOsPath(list(mock_files.keys()))

        lpp = helpers.MockLPP(mock_files)
        lpp.install_fix(usepackage.CopyLocalPkgs())

        lpp.execute(r"""
\documentclass{article}

\usepackage{amsmath}
\usepackage{phfparen}
\usepackage[someoptions,moreoptions]{mymacros}%
\usepackage{cleveref}

\begin{document}
Hello world.
\end{document}
""")
        self.assertEqual(lpp.copied_files, [
            ('mymacros.sty', '/TESTOUT/mymacros.sty'),
            ('cleveref.sty', '/TESTOUT/cleveref.sty'),
        ])
示例#2
0
    def test_simple(self):

        input.os_path = helpers.FakeOsPath([
            # list of files that "exist"
            'chapter1.tex',
            'chapter2.latex',
        ])

        ei = input.EvalInput()

        ei._read_file_contents = lambda fn: {
            'chapter1.tex':
            r"""
\chapter[first]{Chapter uno}
This is the \emph{contents} of ``Chapter 1.''
""",
            'chapter2.latex':
            r"""\chapter{The second of chapters}
Here is the \textbf{contents} of ``Chapter 2!''
""",
        }.get(fn)

        lpp = helpers.MockLPP()
        lpp.install_fix(ei)

        self.assertEqual(
            lpp.execute(r"""
Hello, this might be an introduction:
\[ a + b = c\ . \]

\input{chapter1.tex}

\include{chapter2}
"""), r"""
Hello, this might be an introduction:
\[ a + b = c\ . \]


\chapter[first]{Chapter uno}
This is the \emph{contents} of ``Chapter 1.''


\clearpage
\chapter{The second of chapters}
Here is the \textbf{contents} of ``Chapter 2!''

""")

        self.assertEqual(lpp.copied_files, [])
示例#3
0
    def test_simple_2(self):

        figures.os_path = helpers.FakeOsPath([
            # list of files that "exist"
            'fig/intro.png',
            'my_diagram.jpg',
            'v088338-1993.out.eps',
            'fignew/results schematic.pdf',
            'fignew/results schematic 2.jpg'
        ])
            
        
        lpp = helpers.MockLPP()
        lpp.install_fix( figures.CopyAndRenameFigs(
            start_fig_counter=9,
            fig_rename='fig/{fig_counter}/{orig_fig_basename}{fig_ext}',
            
        ) )

        self.assertEqual(
            lpp.execute(r"""
                \includegraphics[width=\textwidth]{fig/intro}
                \includegraphics[width=\textwidth]{my_diagram.jpg}
                \includegraphics{fignew/results schematic}
                \includegraphics{v088338-1993.out}
            """),
            r"""
                \includegraphics[width=\textwidth]{fig/9/intro.png}
                \includegraphics[width=\textwidth]{fig/10/my_diagram.jpg}
                \includegraphics{fig/11/results schematic.pdf}
                \includegraphics{fig/12/v088338-1993.out.eps}
            """
        )

        self.assertEqual(
            lpp.copied_files,
            [
                ('fig/intro.png', '/TESTOUT/fig/9/intro.png'),
                ('my_diagram.jpg', '/TESTOUT/fig/10/my_diagram.jpg'),
                ('fignew/results schematic.pdf', '/TESTOUT/fig/11/results schematic.pdf'),
                ('v088338-1993.out.eps', '/TESTOUT/fig/12/v088338-1993.out.eps'),
            ]
        )
示例#4
0
    def test_simple(self):

        input.os_path = helpers.FakeOsPath([
            # list of files that "exist"
            'chapter1.tex',
            'chapter2.latex',
        ])

        mock_files = {
            'chapter1.tex':
            r"""
\chapter[first]{Chapter uno}
This is the \emph{contents} of ``Chapter 1.''
""",
            'chapter2.latex':
            r"""\chapter{The second of chapters}
Here is the \textbf{contents} of ``Chapter 2!''
""",
        }

        lpp = helpers.MockLPP(mock_files=mock_files)
        lpp.install_fix(input.CopyInputDeps())

        self.assertEqual(
            lpp.execute(r"""
Hello, this might be an introduction:
\[ a + b = c\ . \]

\input{chapter1.tex}

\include{chapter2}
"""), r"""
Hello, this might be an introduction:
\[ a + b = c\ . \]

\input{chapter1.tex}

\include{chapter2}
""")  # no change

        self.assertEqual(lpp.wrote_executed_files, mock_files)
示例#5
0
    def test_simple_1(self):

        figures.os_path = helpers.FakeOsPath([
            # list of files that "exist"
            'fig/intro.png',
            'my_diagram.jpg',
            'v088338-1993.out.eps',
            'fignew/results schematic.pdf',
            'fignew/results schematic 2.jpg'
        ])
        
        lpp = helpers.MockLPP()
        lpp.install_fix( figures.CopyAndRenameFigs() )

        self.assertEqual(
            lpp.execute(r"""
                \includegraphics[width=\textwidth]{fig/intro}
                \includegraphics[width=\textwidth]{my_diagram.jpg}
                \includegraphics{fignew/results schematic}
                \includegraphics{v088338-1993.out}
            """),
            r"""
                \includegraphics[width=\textwidth]{fig-01.png}
                \includegraphics[width=\textwidth]{fig-02.jpg}
                \includegraphics{fig-03.pdf}
                \includegraphics{fig-04.eps}
            """
        )

        self.assertEqual(
            lpp.copied_files,
            [
                ('fig/intro.png', '/TESTOUT/fig-01.png'),
                ('my_diagram.jpg', '/TESTOUT/fig-02.jpg'),
                ('fignew/results schematic.pdf', '/TESTOUT/fig-03.pdf'),
                ('v088338-1993.out.eps', '/TESTOUT/fig-04.eps'),
            ]
        )