Spaces:
Sleeping
Sleeping
File size: 2,344 Bytes
f65fe85 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# book_base_test.py
#
# This file is part of LilyPond, the GNU music typesetter.
#
# Copyright (C) 2020--2020 Han-Wen Nienhuys <[email protected]>
#
# LilyPond is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# LilyPond is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
import unittest
import book_base
import book_snippets
import book_texinfo
class Dummy:
pass
class TestFindSnippets(unittest.TestCase):
def test_basic_texi(self):
formatter = book_texinfo.BookTexinfoOutputFormat()
global_options = Dummy()
global_options.information = {"program_version": "1.2.3"}
chunks = book_base.find_toplevel_snippets(r"""\input texinfo @c -*- coding: utf-8; mode: texinfo; -*- 1
@setfilename texinfo-include-file.info 2
@settitle Include lilypond files in texinfo 3
4
@node Top 5
@top Include lilypond files in texinfo 6
Lilypond files included in texinfo without any options: 8
@lilypondfile{input/regression/les-nereides.ly}
From a subdirectory: 12
@lilypondfile{input/regression/morgenlied.ly}
Within a lilypond block: 16
@lilypond
% \include "include/myvar.ily"
\relative c'' { c e g }
@end lilypond
Include a file that includes a file:
""", formatter, global_options)
# comment
types = [book_snippets.Substring,
book_snippets.Snippet, # @c
book_snippets.Substring,
book_snippets.LilypondFileSnippet,
book_snippets.Substring,
book_snippets.LilypondFileSnippet,
book_snippets.Substring,
book_snippets.LilypondSnippet,
book_snippets.Substring]
for i in range(0, len(types)):
self.assertIsInstance(chunks[i], types[i])
self.assertEqual(chunks[7].line_number, 18)
if __name__ == '__main__':
unittest.main()
|