def test_on_doctree_read_01(self):
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(self.source_one)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(
            r"""
            <document source="test">
                <literal_block xml:space="preserve">
                    >>> string = 'Hello, world!'
                <literal_block xml:space="preserve">
                    def example_function(expr):
                        r'''This is a multiline docstring.

                        This is the third line of the docstring.
                        '''
                        # This is a comment.
                        print('Entering example function.')
                        try:
                            expr = expr + 1
                        except TypeError:
                            print('Wrong type!')
                        print(expr)
                        print('Leaving example function.')
                <literal_block xml:space="preserve">
                    >>> print(string)
                    Hello, world!
                <literal_block xml:space="preserve">
                    >>> example_function(23)
                    Entering example function.
                    24
                    Leaving example function.
            """)
        assert actual == target
Esempio n. 2
0
    def test_from_docutils_abjad_input_block_01(self):
        source = '''
        ..  abjad::

            note = Note("c'4")
            if True:
                note.written_pitch = "ds,"
        '''
        source = stringtools.normalize(source)
        document = abjadbooktools.SphinxDocumentHandler.parse_rst(source)
        block = document[0]
        result = abjadbooktools.CodeBlock.from_docutils_abjad_input_block(block)
        if sys.version_info[0] == 2:
            assert format(result) == stringtools.normalize(r"""
                abjadbooktools.CodeBlock(
                    (
                        u'note = Note("c\'4")',
                        u'if True:',
                        u'    note.written_pitch = "ds,"',
                        ),
                    starting_line_number=2,
                    )
                """)
        else:
            assert format(result) == stringtools.normalize(r"""
                abjadbooktools.CodeBlock(
                    (
                        'note = Note("c\'4")',
                        'if True:',
                        '    note.written_pitch = "ds,"',
                        ),
                    starting_line_number=2,
                    )
                """)
Esempio n. 3
0
    def test_2(self):
        source = textwrap.dedent('''
        ..  abjad::
            :allow-exceptions:
            :hide:
            :no-resize:
            :no-trim:
            :strip-prompt:
            :with-thumbnail:

            note = Note("c'4")
            if True:
                note.written_pitch = "ds,"
        ''')
        document = self.handler.parse_rst(source)
        result = stringtools.normalize(document.pformat())
        expected = stringtools.normalize(r'''
            <document source="test">
                <abjad_input_block allow-exceptions="True" hide="True" no-resize="True" no-trim="True" strip-prompt="True" with-thumbnail="True">
                    <literal_block xml:space="preserve">
                        note = Note("c'4")
                        if True:
                            note.written_pitch = "ds,"
            ''')
        self.assertEqual(result, expected)
    def test_both(self):
        script = commandlinetools.DoctestScript()
        command = [str(self.doctest_path)]
        with systemtools.TemporaryDirectoryChange(str(self.test_path)):
            with systemtools.RedirectedStreams(stdout=self.string_io):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
        assert context_manager.exception.code == 1
        script_output = self.ansi_escape.sub('', self.string_io.getvalue())
        script_output = stringtools.normalize(script_output)
        expected = stringtools.normalize('''
        doctest_test/doctest_fail.py FAILED
        doctest_test/doctest_pass.py OK

        **********************************************************************
        File ".../doctest_test/doctest_fail.py", line 7, in doctest_fail.py
        Failed example:
            True is False
        Expected:
            True
        Got:
            False
        **********************************************************************
        1 items had failures:
            1 of   1 in doctest_fail.py
        ***Test Failed*** 1 failures.

        FAILED: doctest_test/doctest_fail.py

        1 of 2 tests passed in 2 modules.
        '''.replace('/', os.path.sep))
        assert doctest.OutputChecker().check_output(
            expected, script_output,
            doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
            )
    def test_on_doctree_read_06(self):
        source = u'''
        This example demonstrates the power of exploiting redundancy to model
        musical structure. The piece that concerns us here is Ligeti's *Désordre*:
        the first piano study from Book I. Specifically, we will focus on modeling
        the first section of the piece.

        ..  abjad::

            print('Désordre')
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(
            u"""
            <document source="test">
                <paragraph>
                    This example demonstrates the power of exploiting redundancy to model
                    musical structure. The piece that concerns us here is Ligeti's
                    <emphasis>
                        Désordre
                    :
                    the first piano study from Book I. Specifically, we will focus on modeling
                    the first section of the piece.
                <literal_block xml:space="preserve">
                    >>> print('Désordre')
                    Désordre
            """)
        assert actual == target, \
            systemtools.TestManager.diff(actual, target, 'Diff:')
Esempio n. 6
0
    def test_10(self):
        source = r'''
        ..  abjad::
            :hide:
            :no-resize:
            :no-stylesheet:
            :with-thumbnail:

            staff = Staff("c'1 d'1 e'1 f'1 g'1")
            for note in staff[:-1]:
                attach(indicatortools.PageBreak(), note)

            show(staff)
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        node = document[0]
        try:
            abjadbooktools.SphinxDocumentHandler.visit_abjad_output_block_html(
                self.app, node)
        except docutils.nodes.SkipNode:
            pass
        handler.on_build_finished(self.app, None)
        actual = '\n'.join(self.app.body)
        expected = stringtools.normalize(r'''
            <a data-lightbox="group-lilypond-224663e00b24b652df759bda64c86bca48933457.ly" href="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page1.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page1-thumbnail.png" alt=""/>
            </a>
            <a data-lightbox="group-lilypond-224663e00b24b652df759bda64c86bca48933457.ly" href="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page2.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page2-thumbnail.png" alt=""/>
            </a>
            <a data-lightbox="group-lilypond-224663e00b24b652df759bda64c86bca48933457.ly" href="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page3.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page3-thumbnail.png" alt=""/>
            </a>
            <a data-lightbox="group-lilypond-224663e00b24b652df759bda64c86bca48933457.ly" href="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page4.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page4-thumbnail.png" alt=""/>
            </a>
            <a data-lightbox="group-lilypond-224663e00b24b652df759bda64c86bca48933457.ly" href="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page5.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-224663e00b24b652df759bda64c86bca48933457-page5-thumbnail.png" alt=""/>
            </a>
            ''')
        self.assertEqual(actual, expected)
        assert len(os.listdir(self.abjadbook_images_directory)) == 11
        for name in (
                'lilypond-224663e00b24b652df759bda64c86bca48933457.ly',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page1.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page1-thumbnail.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page2.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page2-thumbnail.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page3.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page3-thumbnail.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page4.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page4-thumbnail.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page5.png',
                'lilypond-224663e00b24b652df759bda64c86bca48933457-page5-thumbnail.png',
        ):
            path = os.path.join(self.images_directory, 'abjadbook', name)
            assert os.path.exists(path)
    def test_10(self):
        source = r'''
        ..  abjad::
            :hide:
            :no-resize:
            :no-stylesheet:
            :with-thumbnail:

            staff = Staff("c'1 d'1 e'1 f'1 g'1")
            for note in staff[:-1]:
                attach(indicatortools.PageBreak(), note)

            show(staff)
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        node = document[0]
        try:
            abjadbooktools.SphinxDocumentHandler.visit_abjad_output_block_html(
                self.app, node)
        except docutils.nodes.SkipNode:
            pass
        handler.on_build_finished(self.app, None)
        actual = '\n'.join(self.app.body)
        expected = stringtools.normalize(r'''
            <a data-lightbox="group-lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a.ly" href="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page1.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page1-thumbnail.png" alt=""/>
            </a>
            <a data-lightbox="group-lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a.ly" href="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page2.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page2-thumbnail.png" alt=""/>
            </a>
            <a data-lightbox="group-lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a.ly" href="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page3.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page3-thumbnail.png" alt=""/>
            </a>
            <a data-lightbox="group-lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a.ly" href="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page4.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page4-thumbnail.png" alt=""/>
            </a>
            <a data-lightbox="group-lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a.ly" href="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page5.png" title="" data-title="" class="abjadbook thumbnail">
                <img src="../_images/abjadbook/lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page5-thumbnail.png" alt=""/>
            </a>
            ''')
        self.assertEqual(actual, expected)
        assert len(os.listdir(self.abjadbook_images_directory)) == 11
        for name in (
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a.ly',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page1.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page1-thumbnail.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page2.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page2-thumbnail.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page3.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page3-thumbnail.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page4.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page4-thumbnail.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page5.png',
            'lilypond-de10d0db01d2644c7aea9703f6ed8c78d8dbb89a-page5-thumbnail.png',
            ):
            path = os.path.join(self.images_directory, 'abjadbook', name)
            assert os.path.exists(path)
Esempio n. 8
0
    def test_from_docutils_abjad_input_block_01(self):
        source = '''
        ..  abjad::

            note = Note("c'4")
            if True:
                note.written_pitch = "ds,"
        '''
        source = stringtools.normalize(source)
        document = abjadbooktools.SphinxDocumentHandler.parse_rst(source)
        block = document[0]
        result = abjadbooktools.CodeBlock.from_docutils_abjad_input_block(block)
        if sys.version_info[0] == 2:
            assert format(result) == stringtools.normalize(r"""
                abjadbooktools.CodeBlock(
                    (
                        u'note = Note("c\'4")',
                        u'if True:',
                        u'    note.written_pitch = "ds,"',
                        ),
                    starting_line_number=2,
                    )
                """)
        else:
            assert format(result) == stringtools.normalize(r"""
                abjadbooktools.CodeBlock(
                    (
                        'note = Note("c\'4")',
                        'if True:',
                        '    note.written_pitch = "ds,"',
                        ),
                    starting_line_number=2,
                    )
                """)
    def test_on_doctree_read_01(self):
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(self.source_one)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(r"""
            <document source="test">
                <literal_block xml:space="preserve">
                    >>> string = 'Hello, world!'
                <literal_block xml:space="preserve">
                    def example_function(expr):
                        r'''This is a multiline docstring.

                        This is the third line of the docstring.
                        '''
                        # This is a comment.
                        print('Entering example function.')
                        try:
                            expr = expr + 1
                        except TypeError:
                            print('Wrong type!')
                        print(expr)
                        print('Leaving example function.')
                <literal_block xml:space="preserve">
                    >>> print(string)
                    Hello, world!
                <literal_block xml:space="preserve">
                    >>> example_function(23)
                    Entering example function.
                    24
                    Leaving example function.
            """)
        assert actual == target
Esempio n. 10
0
    def test_2(self):
        source = textwrap.dedent('''
        ..  abjad::
            :allow-exceptions:
            :hide:
            :no-resize:
            :no-trim:
            :strip-prompt:
            :with-thumbnail:

            note = Note("c'4")
            if True:
                note.written_pitch = "ds,"
        ''')
        document = self.handler.parse_rst(source)
        result = stringtools.normalize(document.pformat())
        expected = stringtools.normalize(
            r'''
            <document source="test">
                <abjad_input_block allow-exceptions="True" hide="True" no-resize="True" no-trim="True" strip-prompt="True" with-thumbnail="True">
                    <literal_block xml:space="preserve">
                        note = Note("c'4")
                        if True:
                            note.written_pitch = "ds,"
            ''')
        self.assertEqual(result, expected)
    def test_on_doctree_read_06(self):
        source = u'''
        This example demonstrates the power of exploiting redundancy to model
        musical structure. The piece that concerns us here is Ligeti's *Désordre*:
        the first piano study from Book I. Specifically, we will focus on modeling
        the first section of the piece.

        ..  abjad::

            print('Désordre')
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(u"""
            <document source="test">
                <paragraph>
                    This example demonstrates the power of exploiting redundancy to model
                    musical structure. The piece that concerns us here is Ligeti's
                    <emphasis>
                        Désordre
                    :
                    the first piano study from Book I. Specifically, we will focus on modeling
                    the first section of the piece.
                <literal_block xml:space="preserve">
                    >>> print('Désordre')
                    Désordre
            """)
        assert actual == target, \
            systemtools.TestManager.diff(actual, target, 'Diff:')
Esempio n. 12
0
    def test_both(self):
        script = commandlinetools.DoctestScript()
        command = [str(self.doctest_path)]
        with systemtools.TemporaryDirectoryChange(str(self.test_path)):
            with systemtools.RedirectedStreams(stdout=self.string_io):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
        assert context_manager.exception.code == 1
        script_output = self.ansi_escape.sub('', self.string_io.getvalue())
        script_output = stringtools.normalize(script_output)
        expected = stringtools.normalize('''
        doctest_test/doctest_fail.py FAILED
        doctest_test/doctest_pass.py OK

        **********************************************************************
        File ".../doctest_test/doctest_fail.py", line 7, in doctest_fail.py
        Failed example:
            True is False
        Expected:
            True
        Got:
            False
        **********************************************************************
        1 items had failures:
            1 of   1 in doctest_fail.py
        ***Test Failed*** 1 failures.

        FAILED: doctest_test/doctest_fail.py

        1 passed, 1 failed out of 2 tests in 2 modules.
        '''.replace('/', os.path.sep))
        self.compare_strings(expected, script_output)
    def test_02(self):
        source = r'''
        ..  abjad::
            :hide:
            :no-stylesheet:
            :no-trim:

            show(Staff("c'4 d'4 e'4 f'4"))
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        node = document[0]
        try:
            abjadbooktools.SphinxDocumentHandler.visit_abjad_output_block_html(
                self.app, node)
        except docutils.nodes.SkipNode:
            pass
        handler.on_build_finished(self.app, None)
        actual = '\n'.join(self.app.body)
        expected = stringtools.normalize(r'''
            <a href="../_images/abjadbook/lilypond-7c082e5b0333af69778f9036846687b8e339e94b.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-7c082e5b0333af69778f9036846687b8e339e94b.png" alt=""/>
            </a>
            ''')
        self.assertEqual(actual, expected)
        assert len(os.listdir(self.abjadbook_images_directory)) == 2
        for name in (
            'lilypond-7c082e5b0333af69778f9036846687b8e339e94b.ly',
            'lilypond-7c082e5b0333af69778f9036846687b8e339e94b.png',
            ):
            path = os.path.join(self.images_directory, 'abjadbook', name)
            assert os.path.exists(path)
Esempio n. 14
0
    def test_diff(self):
        script = commandlinetools.DoctestScript()
        command = ['--diff', str(self.failing_module_path)]
        with systemtools.TemporaryDirectoryChange(str(self.test_path)):
            with systemtools.RedirectedStreams(stdout=self.string_io):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
        assert context_manager.exception.code == 1
        script_output = self.ansi_escape.sub('', self.string_io.getvalue())
        script_output = stringtools.normalize(script_output)
        expected = stringtools.normalize('''
        doctest_test/doctest_fail.py FAILED

        **********************************************************************
        File ".../doctest_test/doctest_fail.py", line 7, in doctest_fail.py
        Failed example:
            True is False
        Differences (ndiff with -expected +actual):
            - True
            + False
        **********************************************************************
        1 items had failures:
            1 of   1 in doctest_fail.py
        ***Test Failed*** 1 failures.

        FAILED: doctest_test/doctest_fail.py

        0 passed, 1 failed out of 1 test in 1 module.
        '''.replace('/', os.path.sep))
        self.compare_strings(expected, script_output)
Esempio n. 15
0
    def test_02(self):
        source = r'''
        ..  abjad::
            :hide:
            :no-stylesheet:
            :no-trim:

            show(Staff("c'4 d'4 e'4 f'4"))
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        node = document[0]
        try:
            abjadbooktools.SphinxDocumentHandler.visit_abjad_output_block_html(
                self.app, node)
        except docutils.nodes.SkipNode:
            pass
        handler.on_build_finished(self.app, None)
        actual = '\n'.join(self.app.body)
        expected = stringtools.normalize(r'''
            <a href="../_images/abjadbook/lilypond-32d88a2354ecb601e788a6d43e67625f59dc61d1.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-32d88a2354ecb601e788a6d43e67625f59dc61d1.png" alt=""/>
            </a>
            ''')
        self.assertEqual(actual, expected)
        assert len(os.listdir(self.abjadbook_images_directory)) == 2
        for name in (
                'lilypond-32d88a2354ecb601e788a6d43e67625f59dc61d1.ly',
                'lilypond-32d88a2354ecb601e788a6d43e67625f59dc61d1.png',
        ):
            path = os.path.join(self.images_directory, 'abjadbook', name)
            assert os.path.exists(path)
Esempio n. 16
0
 def rebuild_document(self, document, blocks):
     for old_node, code_block in reversed(tuple(blocks.items())):
         new_nodes = code_block.as_docutils()
         if (len(new_nodes) == 1
                 and stringtools.normalize(old_node.pformat())
                 == stringtools.normalize(new_nodes[0].pformat())):
             continue
         old_node.parent.replace(old_node, new_nodes)
Esempio n. 17
0
 def test_from_docutils_abjad_import_block_01(self):
     source = '''
     ..  import:: abjad.tools.abjadbooktools:example_function
     '''
     source = stringtools.normalize(source)
     document = abjadbooktools.SphinxDocumentHandler.parse_rst(source)
     block = document[0]
     result = abjadbooktools.CodeBlock.from_docutils_abjad_import_block(block)
     if sys.version_info[0] == 2:
         assert format(result) == stringtools.normalize(r"""
             abjadbooktools.CodeBlock(
                 (
                     u'def example_function(expr):',
                     u"    r'''This is a multiline docstring.",
                     u'',
                     u'    This is the third line of the docstring.',
                     u"    '''",
                     u'    # This is a comment.',
                     u"    print('Entering example function.')",
                     u'    try:',
                     u'        expr = expr + 1',
                     u'    except TypeError:',
                     u"        print('Wrong type!')",
                     u'    print(expr)',
                     u"    print('Leaving example function.')",
                     ),
                 executed_lines=(
                     'from abjad.tools.abjadbooktools import example_function',
                     ),
                 starting_line_number=1,
                 )
             """)
     else:            
         assert format(result) == stringtools.normalize(r"""
             abjadbooktools.CodeBlock(
                 (
                     'def example_function(expr):',
                     "    r'''This is a multiline docstring.",
                     '',
                     '    This is the third line of the docstring.',
                     "    '''",
                     '    # This is a comment.',
                     "    print('Entering example function.')",
                     '    try:',
                     '        expr = expr + 1',
                     '    except TypeError:',
                     "        print('Wrong type!')",
                     '    print(expr)',
                     "    print('Leaving example function.')",
                     ),
                 executed_lines=(
                     'from abjad.tools.abjadbooktools import example_function',
                     ),
                 starting_line_number=1,
                 )
             """)
Esempio n. 18
0
 def test_from_docutils_abjad_import_block_01(self):
     source = '''
     ..  import:: abjad.tools.abjadbooktools:example_function
     '''
     source = stringtools.normalize(source)
     document = abjadbooktools.SphinxDocumentHandler.parse_rst(source)
     block = document[0]
     result = abjadbooktools.CodeBlock.from_docutils_abjad_import_block(block)
     if sys.version_info[0] == 2:
         assert format(result) == stringtools.normalize(r"""
             abjadbooktools.CodeBlock(
                 (
                     u'def example_function(expr):',
                     u"    r'''This is a multiline docstring.",
                     u'',
                     u'    This is the third line of the docstring.',
                     u"    '''",
                     u'    # This is a comment.',
                     u"    print('Entering example function.')",
                     u'    try:',
                     u'        expr = expr + 1',
                     u'    except TypeError:',
                     u"        print('Wrong type!')",
                     u'    print(expr)',
                     u"    print('Leaving example function.')",
                     ),
                 executed_lines=(
                     'from abjad.tools.abjadbooktools import example_function',
                     ),
                 starting_line_number=1,
                 )
             """)
     else:            
         assert format(result) == stringtools.normalize(r"""
             abjadbooktools.CodeBlock(
                 (
                     'def example_function(expr):',
                     "    r'''This is a multiline docstring.",
                     '',
                     '    This is the third line of the docstring.',
                     "    '''",
                     '    # This is a comment.',
                     "    print('Entering example function.')",
                     '    try:',
                     '        expr = expr + 1',
                     '    except TypeError:',
                     "        print('Wrong type!')",
                     '    print(expr)',
                     "    print('Leaving example function.')",
                     ),
                 executed_lines=(
                     'from abjad.tools.abjadbooktools import example_function',
                     ),
                 starting_line_number=1,
                 )
             """)
    def test_on_doctree_read_05(self):
        source = r'''
        ..  abjad::
            :text-width: 40

            [x for x in dir() if not x.startswith('_')]
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(r"""
            <document source="test">
                <literal_block xml:space="preserve">
                    >>> [x for x in dir() if not x.startswith('_')]
                    ['Accelerando', 'Articulation', 'Beam',
                    'Chord', 'Clef', 'Container', 'Context',
                    'Crescendo', 'Decrescendo', 'Duration',
                    'Dynamic', 'Fermata', 'Fraction',
                    'Glissando', 'Hairpin', 'KeySignature',
                    'LilyPondCommand', 'Markup', 'Measure',
                    'MultimeasureRest', 'Multiplier',
                    'NamedPitch', 'Note', 'Offset', 'Ratio',
                    'Rest', 'Ritardando', 'Score',
                    'Sequence', 'Skip', 'Slur', 'Staff',
                    'StaffGroup', 'Tempo', 'Tie',
                    'TimeSignature', 'Timespan', 'Tuplet',
                    'Voice', 'abctools',
                    'abjad_configuration', 'agenttools',
                    'attach', 'commandlinetools',
                    'datastructuretools', 'demos', 'detach',
                    'documentationtools', 'durationtools',
                    'exceptiontools', 'expressiontools',
                    'ext', 'f', 'graph', 'indicatortools',
                    'inspect_', 'instrumenttools',
                    'ipythontools', 'iterate', 'label',
                    'lilypondfiletools',
                    'lilypondnametools',
                    'lilypondparsertools', 'ly',
                    'markuptools', 'mathtools',
                    'metertools', 'mutate', 'new',
                    'override', 'parse', 'patterntools',
                    'persist', 'pitchtools', 'play',
                    'print_function', 'quantizationtools',
                    'rhythmmakertools', 'rhythmtreetools',
                    'schemetools', 'scoretools', 'select',
                    'selectiontools', 'selectortools',
                    'sequence', 'sequencetools', 'set_',
                    'show', 'spannertools', 'stringtools',
                    'systemtools', 'templatetools',
                    'timespantools', 'tonalanalysistools',
                    'topleveltools']
            """)
        assert actual == target, \
            systemtools.TestManager.diff(actual, target, 'Diff:')
    def test_on_doctree_read_05(self):
        source = r'''
        ..  abjad::
            :text-width: 40

            [x for x in dir() if not x.startswith('_')]
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(
            r"""
            <document source="test">
                <literal_block xml:space="preserve">
                    >>> [x for x in dir() if not x.startswith('_')]
                    ['Accelerando', 'Articulation', 'Beam',
                    'Chord', 'Clef', 'Container', 'Context',
                    'Crescendo', 'Decrescendo', 'Duration',
                    'Dynamic', 'Fermata', 'Fraction',
                    'Glissando', 'Hairpin', 'KeySignature',
                    'Markup', 'Measure', 'MultimeasureRest',
                    'Multiplier', 'NamedPitch', 'Note',
                    'Offset', 'Ratio', 'Rest', 'Ritardando',
                    'Score', 'Sequence', 'Skip', 'Slur',
                    'Staff', 'StaffGroup', 'Tempo', 'Tie',
                    'TimeSignature', 'Timespan', 'Tuplet',
                    'Voice', 'abctools',
                    'abjad_configuration', 'agenttools',
                    'attach', 'datastructuretools', 'demos',
                    'detach', 'developerscripttools',
                    'documentationtools', 'durationtools',
                    'exceptiontools', 'expressiontools',
                    'ext', 'f', 'graph', 'handlertools',
                    'indicatortools', 'inspect_',
                    'instrumenttools', 'ipythontools',
                    'iterate', 'label', 'lilypondfiletools',
                    'lilypondnametools',
                    'lilypondparsertools', 'ly',
                    'markuptools', 'mathtools',
                    'metertools', 'mutate', 'new',
                    'override', 'parse', 'patterntools',
                    'persist', 'pitchtools', 'play',
                    'print_function', 'quantizationtools',
                    'rhythmmakertools', 'rhythmtreetools',
                    'schemetools', 'scoretools', 'select',
                    'selectiontools', 'selectortools',
                    'sequence', 'sequencetools', 'set_',
                    'show', 'spannertools', 'stringtools',
                    'systemtools', 'templatetools',
                    'timespantools', 'tonalanalysistools',
                    'topleveltools']
            """)
        assert actual == target, \
            systemtools.TestManager.diff(actual, target, 'Diff:')
Esempio n. 21
0
 def rebuild_document(self, document, blocks):
     for old_node, code_block in reversed(tuple(blocks.items())):
         new_nodes = code_block.as_docutils()
         if (
             len(new_nodes) == 1 and
             stringtools.normalize(old_node.pformat()) ==
             stringtools.normalize(new_nodes[0].pformat())
             ):
             continue
         old_node.parent.replace(old_node, new_nodes)
Esempio n. 22
0
    def test_09(self):
        source = r'''
        ..  abjad::
            :hide:
            :no-stylesheet:
            :no-trim:
            :pages: 2-4
            :with-columns: 2

            staff = Staff("c'1 d'1 e'1 f'1 g'1")
            for note in staff[:-1]:
                attach(indicatortools.PageBreak(), note)

            show(staff)
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        node = document[0]
        try:
            abjadbooktools.SphinxDocumentHandler.visit_abjad_output_block_html(
                self.app, node)
        except docutils.nodes.SkipNode:
            pass
        handler.on_build_finished(self.app, None)
        actual = '\n'.join(self.app.body)
        expected = stringtools.normalize(r'''
            <div class="table-row">
                <a href="../_images/abjadbook/lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a.ly" title="" class="table-cell">
                    <img src="../_images/abjadbook/lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a-page2.png" alt=""/>
                </a>
                <a href="../_images/abjadbook/lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a.ly" title="" class="table-cell">
                    <img src="../_images/abjadbook/lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a-page3.png" alt=""/>
                </a>
            </div>
            <div class="table-row">
                <a href="../_images/abjadbook/lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a.ly" title="" class="table-cell">
                    <img src="../_images/abjadbook/lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a-page4.png" alt=""/>
                </a>
            </div>
            ''')
        self.assertEqual(actual, expected)
        assert len(os.listdir(self.abjadbook_images_directory)) == 6
        for name in (
                'lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a.ly',
                'lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a-page1.png',
                'lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a-page2.png',
                'lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a-page3.png',
                'lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a-page4.png',
                'lilypond-1113b742beda3b13163bb7fe4bbdd6787edc3c1a-page5.png',
        ):
            path = os.path.join(self.images_directory, 'abjadbook', name)
            assert os.path.exists(path)
Esempio n. 23
0
 def test_1(self):
     source = textwrap.dedent('''
     ..  import:: abjad.tools.scoretools.make_notes
     ''')
     document = self.handler.parse_rst(source)
     result = stringtools.normalize(document.pformat())
     expected = stringtools.normalize(r'''
         <document source="test">
             <abjad_import_block path="abjad.tools.scoretools.make_notes">
         ''')
     self.assertEqual(result, expected)
    def test_09(self):
        source = r'''
        ..  abjad::
            :hide:
            :no-stylesheet:
            :no-trim:
            :pages: 2-4
            :with-columns: 2

            staff = Staff("c'1 d'1 e'1 f'1 g'1")
            for note in staff[:-1]:
                attach(indicatortools.PageBreak(), note)

            show(staff)
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        node = document[0]
        try:
            abjadbooktools.SphinxDocumentHandler.visit_abjad_output_block_html(
                self.app, node)
        except docutils.nodes.SkipNode:
            pass
        handler.on_build_finished(self.app, None)
        actual = '\n'.join(self.app.body)
        expected = stringtools.normalize(r'''
            <div class="table-row">
                <a href="../_images/abjadbook/lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f.ly" title="" class="table-cell">
                    <img src="../_images/abjadbook/lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f-page2.png" alt=""/>
                </a>
                <a href="../_images/abjadbook/lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f.ly" title="" class="table-cell">
                    <img src="../_images/abjadbook/lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f-page3.png" alt=""/>
                </a>
            </div>
            <div class="table-row">
                <a href="../_images/abjadbook/lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f.ly" title="" class="table-cell">
                    <img src="../_images/abjadbook/lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f-page4.png" alt=""/>
                </a>
            </div>
            ''')
        self.assertEqual(actual, expected)
        assert len(os.listdir(self.abjadbook_images_directory)) == 6
        for name in (
            'lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f.ly',
            'lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f-page1.png',
            'lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f-page2.png',
            'lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f-page3.png',
            'lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f-page4.png',
            'lilypond-c58647743390ca8f866acf83a0d7efbf9b84d67f-page5.png',
            ):
            path = os.path.join(self.images_directory, 'abjadbook', name)
            assert os.path.exists(path)
Esempio n. 25
0
 def test_1(self):
     source = textwrap.dedent('''
     ..  import:: abjad.tools.scoretools.make_notes
     ''')
     document = self.handler.parse_rst(source)
     result = stringtools.normalize(document.pformat())
     expected = stringtools.normalize(
         r'''
         <document source="test">
             <abjad_import_block path="abjad.tools.scoretools.make_notes">
         ''')
     self.assertEqual(result, expected)
Esempio n. 26
0
    def test_06(self):
        source = r'''
        ..  abjad::
            :hide:
            :no-stylesheet:

            staff = Staff("c'1 d'1 e'1 f'1 g'1")
            for note in staff[:-1]:
                attach(indicatortools.PageBreak(), note)

            show(staff)
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        node = document[0]
        try:
            abjadbooktools.SphinxDocumentHandler.visit_abjad_output_block_html(
                self.app, node)
        except docutils.nodes.SkipNode:
            pass
        handler.on_build_finished(self.app, None)
        actual = '\n'.join(self.app.body)
        expected = stringtools.normalize(r'''
            <a href="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page1.png" alt=""/>
            </a>
            <a href="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page2.png" alt=""/>
            </a>
            <a href="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page3.png" alt=""/>
            </a>
            <a href="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page4.png" alt=""/>
            </a>
            <a href="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page5.png" alt=""/>
            </a>
            ''')
        self.assertEqual(actual, expected)
        assert len(os.listdir(self.abjadbook_images_directory)) == 6
        for name in (
                'lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7.ly',
                'lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page1.png',
                'lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page2.png',
                'lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page3.png',
                'lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page4.png',
                'lilypond-f75159c51f466ac3f0427cda3f86fba7bb709ae7-page5.png',
        ):
            path = os.path.join(self.images_directory, 'abjadbook', name)
            assert os.path.exists(path)
Esempio n. 27
0
File: base.py Progetto: ajyoon/abjad
 def compare_lilypond_contents(self, ly_path, expected_contents):
     expected_contents = stringtools.normalize(expected_contents)
     with open(str(ly_path), 'r') as file_pointer:
         contents = file_pointer.read()
     if ly_path.suffix == '.ly':
         contents = contents.splitlines()
         while 'version' not in contents[0]:
             contents.pop(0)
         contents.pop(0)
         contents = '\n'.join(contents)
     contents = stringtools.normalize(contents)
     self.compare_strings(expected_contents, contents)
    def test_06(self):
        source = r'''
        ..  abjad::
            :hide:
            :no-stylesheet:

            staff = Staff("c'1 d'1 e'1 f'1 g'1")
            for note in staff[:-1]:
                attach(indicatortools.PageBreak(), note)

            show(staff)
        '''
        source = stringtools.normalize(source)
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        node = document[0]
        try:
            abjadbooktools.SphinxDocumentHandler.visit_abjad_output_block_html(
                self.app, node)
        except docutils.nodes.SkipNode:
            pass
        handler.on_build_finished(self.app, None)
        actual = '\n'.join(self.app.body)
        expected = stringtools.normalize(r'''
            <a href="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page1.png" alt=""/>
            </a>
            <a href="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page2.png" alt=""/>
            </a>
            <a href="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page3.png" alt=""/>
            </a>
            <a href="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page4.png" alt=""/>
            </a>
            <a href="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365.ly" title="" class="abjadbook">
                <img src="../_images/abjadbook/lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page5.png" alt=""/>
            </a>
            ''')
        self.assertEqual(actual, expected)
        assert len(os.listdir(self.abjadbook_images_directory)) == 6
        for name in (
            'lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365.ly',
            'lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page1.png',
            'lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page2.png',
            'lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page3.png',
            'lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page4.png',
            'lilypond-4b0885a24cb0c0f7d7f825826532e89575af5365-page5.png',
            ):
            path = os.path.join(self.images_directory, 'abjadbook', name)
            assert os.path.exists(path)
Esempio n. 29
0
    def test_02(self):

        synth = servertools.Synth(synthdefs.test)
        synth['frequency'].set(443)
        synth['amplitude'].set(0.5)

        assert synth['frequency'].get() == 443
        assert synth['amplitude'].get() == 0.5

        synth.allocate()

        server_state = str(
            self.server.query_remote_nodes(include_controls=True))
        assert server_state == stringtools.normalize(
            r'''
            NODE TREE 0 group
                1 group
                    1000 test
                        amplitude: 0.5, frequency: 443.0
            ''', )

        synth.free()

        assert synth['frequency'].get() == 443
        assert synth['amplitude'].get() == 0.5

        control_bus = servertools.Bus(0, calculation_rate='control')
        audio_bus = servertools.Bus(0, calculation_rate='audio')

        synth['frequency'].set(control_bus)
        synth['amplitude'].set(audio_bus)

        assert synth['frequency'].get() == control_bus
        assert synth['amplitude'].get() == audio_bus

        synth.allocate()

        server_state = str(
            self.server.query_remote_nodes(include_controls=True))
        assert server_state == stringtools.normalize(
            r'''
            NODE TREE 0 group
                1 group
                    1001 test
                        amplitude: a0, frequency: c0
            ''', )

        synth.free()

        assert synth['frequency'].get() == control_bus
        assert synth['amplitude'].get() == audio_bus
Esempio n. 30
0
    def test_02(self):

        synth = servertools.Synth(synthdefs.test)
        synth['frequency'].set(443)
        synth['amplitude'].set(0.5)

        assert synth['frequency'].get() == 443
        assert synth['amplitude'].get() == 0.5

        synth.allocate()

        server_state = str(self.server.query_remote_nodes(include_controls=True))
        assert server_state == stringtools.normalize(r'''
            NODE TREE 0 group
                1 group
                    1000 test
                        amplitude: 0.5, frequency: 443.0
            ''',
            )

        synth.free()

        assert synth['frequency'].get() == 443
        assert synth['amplitude'].get() == 0.5

        control_bus = servertools.Bus(0, calculation_rate='control')
        audio_bus = servertools.Bus(0, calculation_rate='audio')

        synth['frequency'].set(control_bus)
        synth['amplitude'].set(audio_bus)

        assert synth['frequency'].get() == control_bus
        assert synth['amplitude'].get() == audio_bus

        synth.allocate()

        server_state = str(self.server.query_remote_nodes(include_controls=True))
        assert server_state == stringtools.normalize(r'''
            NODE TREE 0 group
                1 group
                    1001 test
                        amplitude: a0, frequency: c0
            ''',
            )

        synth.free()

        assert synth['frequency'].get() == control_bus
        assert synth['amplitude'].get() == audio_bus
Esempio n. 31
0
    def test_1(self):
        source = textwrap.dedent('''
        ..  shell::

            echo "foo"
        ''')
        document = self.handler.parse_rst(source)
        result = stringtools.normalize(document.pformat())
        expected = stringtools.normalize(r'''
            <document source="test">
                <literal_block language="console" xml:space="preserve">
                    abjad$ echo "foo"
                    foo
            ''')
        self.assertEqual(result, expected)
Esempio n. 32
0
    def test_4(self):
        source = textwrap.dedent('''
        ..  abjad::
            :stylesheet: non-proportional.ly

            show(Note("c'4"))
        ''')
        document = self.handler.parse_rst(source)
        result = stringtools.normalize(document.pformat())
        expected = stringtools.normalize(r'''
            <document source="test">
                <abjad_input_block stylesheet="non-proportional.ly">
                    <literal_block xml:space="preserve">
                        show(Note("c'4"))
            ''')
        self.assertEqual(result, expected)
    def test_abjadextract_3(self):
        input_file_contents = [
            '\\begin{comment}',
            '<abjadextract abjad.tools.abjadbooktools:example_function \>[hide=true]',
            '\\end{comment}',
            '',
            '\\begin{comment}',
            '<abjad>[allow_exceptions=true]',
            "example_function('foo')",
            '</abjad>',
            '\\end{comment}',
            '',
            '\\begin{comment}',
            '<abjad>[allow_exceptions=true]',
            "example_function(23)",
            '</abjad>',
            '\\end{comment}',
            ]
        document_handler = abjadbooktools.LaTeXDocumentHandler(
            input_file_contents=input_file_contents,
            )
        rebuilt_source = document_handler(return_source=True)
        assert rebuilt_source == stringtools.normalize(
            """
            \\begin{comment}
            <abjadextract abjad.tools.abjadbooktools:example_function \\>[hide=true]
            \\end{comment}

            \\begin{comment}
            <abjad>[allow_exceptions=true]
            example_function('foo')
            </abjad>
            \\end{comment}

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            >>> example_function('foo')
            Entering example function.
            Wrong type!
            foo
            Leaving example function.
            \\end{lstlisting}
            %%% ABJADBOOK END %%%

            \\begin{comment}
            <abjad>[allow_exceptions=true]
            example_function(23)
            </abjad>
            \\end{comment}

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            >>> example_function(23)
            Entering example function.
            24
            Leaving example function.
            \\end{lstlisting}
            %%% ABJADBOOK END %%%
            """,
            )
def test_documentationtools_GraphvizGraph_pickle_05():
    graph = documentationtools.GraphvizGraph()
    graph.append(documentationtools.GraphvizSubgraph())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizSubgraph())
    graph[0][-1].append(documentationtools.GraphvizNode())
    graph.append(documentationtools.GraphvizNode())
    documentationtools.GraphvizEdge().attach(graph[0][1], graph[1])
    documentationtools.GraphvizEdge().attach(graph[0][0], graph[0][-1][0])
    assert str(graph) == stringtools.normalize(
        r'''
        digraph G {
            subgraph cluster_0 {
                node_0_0;
                node_0_1;
                node_0_2;
                subgraph cluster_0_3 {
                    node_0_3_0;
                }
                node_0_0 -> node_0_3_0;
            }
            node_1;
            node_0_1 -> node_1;
        }
        '''
        )
    pickled = pickle.loads(pickle.dumps(graph))
    assert str(graph) == str(pickled)
    def test_exception_2(self):
        input_file_contents = [
            '<abjad>[allow_exceptions=true]',
            "'foo' / 19",
            '</abjad>',
            ]
        document_handler = abjadbooktools.LaTeXDocumentHandler(
            input_file_contents=input_file_contents,
            )
        rebuilt_source = document_handler(return_source=True)
        assert rebuilt_source == stringtools.normalize(
            '''
            <abjad>[allow_exceptions=true]
            'foo' / 19
            </abjad>

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            >>> 'foo' / 19
            Traceback (most recent call last):
              File "<stdin>", line 1, in <module>
            TypeError: unsupported operand type(s) for /: 'str' and 'int'
            \\end{lstlisting}
            %%% ABJADBOOK END %%%
            ''',
            )
def test_documentationtools_GraphvizGraph_copy_06():
    graph = documentationtools.GraphvizGraph()
    graph.append(documentationtools.GraphvizSubgraph())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizSubgraph())
    graph[0][-1].append(documentationtools.GraphvizNode())
    graph.append(documentationtools.GraphvizNode())
    documentationtools.GraphvizEdge().attach(graph[0][1], graph[1])
    documentationtools.GraphvizEdge().attach(graph[0][0], graph[0][-1][0])
    copied = copy.copy(graph[0])
    assert str(copied) == stringtools.normalize(
        r'''
        digraph cluster_ {
            node_0;
            node_1;
            node_2;
            subgraph cluster_3 {
                node_3_0;
            }
            node_0 -> node_3_0;
        }
        ''')
    assert copied.parent is None
def test_documentationtools_GraphvizGraph_pickle_05():
    graph = documentationtools.GraphvizGraph()
    graph.append(documentationtools.GraphvizSubgraph())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizSubgraph())
    graph[0][-1].append(documentationtools.GraphvizNode())
    graph.append(documentationtools.GraphvizNode())
    documentationtools.GraphvizEdge().attach(graph[0][1], graph[1])
    documentationtools.GraphvizEdge().attach(graph[0][0], graph[0][-1][0])
    assert str(graph) == stringtools.normalize(r'''
        digraph G {
            subgraph cluster_0 {
                node_0_0;
                node_0_1;
                node_0_2;
                subgraph cluster_0_3 {
                    node_0_3_0;
                }
                node_0_0 -> node_0_3_0;
            }
            node_1;
            node_0_1 -> node_1;
        }
        ''')
    pickled = pickle.loads(pickle.dumps(graph))
    assert str(graph) == str(pickled)
    def test_python_cannot_illustrate(self):
        """
        Handle un-illustrables.
        """
        self.create_score()
        material_path = self.create_material('test_material')
        definition_path = material_path.joinpath('definition.py')
        with open(str(definition_path), 'w') as file_pointer:
            file_pointer.write(
                stringtools.normalize(r'''
            # -*- coding: utf-8 -*-

            test_material = None
            '''))
        script = commandlinetools.ManageMaterialScript()
        command = ['--illustrate', 'test_material']
        with systemtools.RedirectedStreams(stdout=self.string_io):
            with systemtools.TemporaryDirectoryChange(str(self.score_path)):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
                assert context_manager.exception.code == 1
        self.compare_captured_output(r'''
            Illustration candidates: 'test_material' ...
            Illustrating test_score/materials/test_material/
                Importing test_score.materials.test_material.definition
                Cannot illustrate material of type NoneType.
        '''.replace('/', os.path.sep))
def test_documentationtools_GraphvizGraph_deepcopy_05():
    graph = documentationtools.GraphvizGraph()
    graph.append(documentationtools.GraphvizSubgraph())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizSubgraph())
    graph[0][-1].append(documentationtools.GraphvizNode())
    graph.append(documentationtools.GraphvizNode())
    documentationtools.GraphvizEdge().attach(graph[0][1], graph[1])
    documentationtools.GraphvizEdge().attach(graph[0][0], graph[0][-1][0])
    assert str(graph) == stringtools.normalize(r'''
        digraph G {
            subgraph cluster_0 {
                node_0_0;
                node_0_1;
                node_0_2;
                subgraph cluster_0_3 {
                    node_0_3_0;
                }
                node_0_0 -> node_0_3_0;
            }
            node_1;
            node_0_1 -> node_1;
        }
        ''')
    copied = copy.deepcopy(graph)
    assert str(graph) == str(copied)
    def test_python_error_on_illustrate(self):
        """
        Handle exceptions inside the Python module on __call__().
        """
        self.create_score()
        material_path = self.create_material('test_material')
        definition_path = material_path.joinpath('definition.py')
        with open(str(definition_path), 'w') as file_pointer:
            file_pointer.write(
                stringtools.normalize(r'''
            # -*- coding: utf-8 -*-
            from abjad.tools import abctools


            class Foo(object):
                def __illustrate__(self):
                    raise TypeError('This is fake.')

            test_material = Foo()
            '''))
        script = commandlinetools.ManageMaterialScript()
        command = ['--illustrate', 'test_material']
        with systemtools.RedirectedStreams(stdout=self.string_io):
            with systemtools.TemporaryDirectoryChange(str(self.score_path)):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
                assert context_manager.exception.code == 1
        self.compare_captured_output(r'''
            Illustration candidates: 'test_material' ...
            Illustrating test_score/materials/test_material/
                Importing test_score.materials.test_material.definition
        '''.replace('/', os.path.sep))
    def test_python_error_on_illustrate(self):
        """
        Handle exceptions inside the Python module on __call__().
        """
        self.create_score()
        material_path = self.create_material('test_material')
        definition_path = material_path.joinpath('definition.py')
        with open(str(definition_path), 'w') as file_pointer:
            file_pointer.write(stringtools.normalize(r'''
            # -*- coding: utf-8 -*-
            from abjad.tools import abctools


            class Foo(object):
                def __illustrate__(self):
                    raise TypeError('This is fake.')

            test_material = Foo()
            '''))
        script = commandlinetools.ManageMaterialScript()
        command = ['--illustrate', 'test_material']
        with systemtools.RedirectedStreams(stdout=self.string_io):
            with systemtools.TemporaryDirectoryChange(str(self.score_path)):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
                assert context_manager.exception.code == 1
        self.compare_captured_output(r'''
            Illustration candidates: 'test_material' ...
            Illustrating test_score/materials/test_material/
                Importing test_score.materials.test_material.definition
        '''.replace('/', os.path.sep))
    def test_python_cannot_illustrate(self):
        """
        Handle un-illustrables.
        """
        self.create_score()
        material_path = self.create_material('test_material')
        definition_path = material_path.joinpath('definition.py')
        with open(str(definition_path), 'w') as file_pointer:
            file_pointer.write(stringtools.normalize(r'''
            # -*- coding: utf-8 -*-

            test_material = None
            '''))
        script = commandlinetools.ManageMaterialScript()
        command = ['--illustrate', 'test_material']
        with systemtools.RedirectedStreams(stdout=self.string_io):
            with systemtools.TemporaryDirectoryChange(str(self.score_path)):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
                assert context_manager.exception.code == 1
        self.compare_captured_output(r'''
            Illustration candidates: 'test_material' ...
            Illustrating test_score/materials/test_material/
                Importing test_score.materials.test_material.definition
                Cannot illustrate material of type NoneType.
        '''.replace('/', os.path.sep))
def test_documentationtools_GraphvizGraph_deepcopy_05():
    graph = documentationtools.GraphvizGraph()
    graph.append(documentationtools.GraphvizSubgraph())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizNode())
    graph[0].append(documentationtools.GraphvizSubgraph())
    graph[0][-1].append(documentationtools.GraphvizNode())
    graph.append(documentationtools.GraphvizNode())
    documentationtools.GraphvizEdge().attach(graph[0][1], graph[1])
    documentationtools.GraphvizEdge().attach(graph[0][0], graph[0][-1][0])
    assert str(graph) == stringtools.normalize(
        r'''
        digraph G {
            subgraph cluster_0 {
                node_0_0;
                node_0_1;
                node_0_2;
                subgraph cluster_0_3 {
                    node_0_3_0;
                }
                node_0_0 -> node_0_3_0;
            }
            node_1;
            node_0_1 -> node_1;
        }
        '''
        )
    copied = copy.deepcopy(graph)
    assert str(graph) == str(copied)
 def test_2(self):
     source = '''
         <extraartists>
             <artist>
                 <id>239</id>
                 <name>Jesper Dahlb\xe4ck</name>
                 <anv/>
                 <join/>
                 <role>Music By [All Tracks By]</role>
                 <tracks/>
             </artist>
         </extraartists>
         '''
     element = ElementTree.fromstring(source)
     artist_credits = library.ArtistCredit.from_elements(element)
     assert format(artist_credits[0]) == stringtools.normalize(r'''
         discograph.library.mongo.ArtistCredit(
             discogs_id=239,
             name='Jesper Dahlbäck',
             roles=[
                 discograph.library.mongo.CreditRole(
                     detail='All Tracks By',
                     name='Music By',
                     ),
                 ],
             )
         ''')
Esempio n. 45
0
    def test_1(self):
        source = textwrap.dedent('''
        ..  shell::

            echo "foo"
        ''')
        document = self.handler.parse_rst(source)
        result = stringtools.normalize(document.pformat())
        expected = stringtools.normalize(
            r'''
            <document source="test">
                <literal_block language="console" xml:space="preserve">
                    abjad$ echo "foo"
                    foo
            ''')
        self.assertEqual(result, expected)
Esempio n. 46
0
    def test_pass(self):
        script = commandlinetools.DoctestScript()
        command = [str(self.passing_module_path)]
        with systemtools.TemporaryDirectoryChange(str(self.test_path)):
            with systemtools.RedirectedStreams(stdout=self.string_io):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
        assert context_manager.exception.code == 0
        script_output = self.ansi_escape.sub('', self.string_io.getvalue())
        script_output = stringtools.normalize(script_output)
        expected = stringtools.normalize('''
        doctest_test/doctest_pass.py OK

        1 passed, 0 failed out of 1 test in 1 module.
        '''.replace('/', os.path.sep))
        self.compare_strings(expected, script_output)
    def test_syntax_error_2(self):
        input_file_contents = [
            '<abjad>[allow_exceptions=true]',
            'foo bar baz',
            '</abjad>',
            ]
        document_handler = abjadbooktools.LaTeXDocumentHandler(
            input_file_contents=input_file_contents,
            )
        rebuilt_source = document_handler(return_source=True)
        assert rebuilt_source == stringtools.normalize(
            '''
            <abjad>[allow_exceptions=true]
            foo bar baz
            </abjad>

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            >>> foo bar baz
              File "<stdin>", line 1
                foo bar baz
                      ^
            SyntaxError: invalid syntax
            \\end{lstlisting}
            %%% ABJADBOOK END %%%
            ''',
            )
Esempio n. 48
0
    def test_syntax_error_2(self):
        input_file_contents = [
            '<abjad>[allow_exceptions=true]',
            'foo bar baz',
            '</abjad>',
        ]
        document_handler = abjadbooktools.LaTeXDocumentHandler(
            input_file_contents=input_file_contents, )
        rebuilt_source = document_handler(return_source=True)
        assert rebuilt_source == stringtools.normalize(
            '''
            <abjad>[allow_exceptions=true]
            foo bar baz
            </abjad>

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            >>> foo bar baz
              File "<stdin>", line 1
                foo bar baz
                      ^
            SyntaxError: invalid syntax
            \\end{lstlisting}
            %%% ABJADBOOK END %%%
            ''', )
    def test_on_doctree_read_09(self):
        source = '''
        ..  abjad::
            :strip-prompt:

            class Foo(object):

                def bar(self):
                    print('OK')

                def baz(self):
                    print('NO')

                def quux(self):
                    return 23

        ..  abjad::

            foo = Foo()
            foo.quux()
        '''
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(
            r"""
            <document source="test">
                <block_quote>
                    <literal_block xml:space="preserve">
                        class Foo(object):

                            def bar(self):
                                print('OK')

                            def baz(self):
                                print('NO')

                            def quux(self):
                                return 23
                    <literal_block xml:space="preserve">
                        >>> foo = Foo()
                        >>> foo.quux()
                        23
            """)
        assert actual == target, \
            systemtools.TestManager.diff(actual, target, 'Diff:')
    def test_lilypond_error(self):
        """
        Handle failing LilyPond rendering.
        """
        self.create_score()
        material_path = self.create_material('test_material')
        definition_path = material_path.joinpath('definition.py')
        with open(str(definition_path), 'w') as file_pointer:
            file_pointer.write(
                stringtools.normalize(r'''
            # -*- coding: utf-8 -*-
            from abjad.tools import lilypondfiletools


            test_material = lilypondfiletools.make_basic_lilypond_file()
            test_material.items.append(r'\this-does-not-exist')
            '''))
        script = commandlinetools.ManageMaterialScript()
        command = ['--illustrate', 'test_material']
        with systemtools.RedirectedStreams(stdout=self.string_io):
            with systemtools.TemporaryDirectoryChange(str(self.score_path)):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
                assert context_manager.exception.code == 1
        self.compare_captured_output(r'''
            Illustration candidates: 'test_material' ...
            Illustrating test_score/materials/test_material/
                Importing test_score.materials.test_material.definition
                    Abjad runtime: ... second...
                Writing test_score/materials/test_material/illustration.ly ... OK!
                Writing test_score/materials/test_material/illustration.pdf ... Failed!
        '''.replace('/', os.path.sep))
        illustration_ly_path = material_path.joinpath('illustration.ly')
        assert illustration_ly_path.exists()
        self.compare_lilypond_contents(
            illustration_ly_path,
            stringtools.normalize(r'''
            \language "english"

            \header {}

            \layout {}

            \paper {}

            \this-does-not-exist
            '''))
Esempio n. 51
0
    def test_strip_prompt_2(self):
        input_file_contents = [
            '\\begin{comment}',
            '<abjad>[strip_prompt=true]',
            'def do_something(expr):',
            "    print('before')",
            '    print(expr + 1)',
            "    print('after')",
            '',
            '</abjad>',
            '\\end{comment}',
            '',
            '\\begin{comment}',
            '<abjad>',
            'do_something(23)',
            '</abjad>',
            '\\end{comment}',
            ]
        document_handler = abjadbooktools.LaTeXDocumentHandler(
            input_file_contents=input_file_contents,
            )
        rebuilt_source = document_handler(return_source=True)
        assert rebuilt_source == stringtools.normalize(
            """
            \\begin{comment}
            <abjad>[strip_prompt=true]
            def do_something(expr):
                print('before')
                print(expr + 1)
                print('after')

            </abjad>
            \\end{comment}

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            def do_something(expr):
                print('before')
                print(expr + 1)
                print('after')
            \\end{lstlisting}
            %%% ABJADBOOK END %%%

            \\begin{comment}
            <abjad>
            do_something(23)
            </abjad>
            \\end{comment}

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            >>> do_something(23)
            before
            24
            after
            \\end{lstlisting}
            %%% ABJADBOOK END %%%
            """,
            )
    def test_on_doctree_read_09(self):
        source = '''
        ..  abjad::
            :strip-prompt:

            class Foo(object):

                def bar(self):
                    print('OK')

                def baz(self):
                    print('NO')

                def quux(self):
                    return 23

        ..  abjad::

            foo = Foo()
            foo.quux()
        '''
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(r"""
            <document source="test">
                <block_quote>
                    <literal_block xml:space="preserve">
                        class Foo(object):

                            def bar(self):
                                print('OK')

                            def baz(self):
                                print('NO')

                            def quux(self):
                                return 23
                    <literal_block xml:space="preserve">
                        >>> foo = Foo()
                        >>> foo.quux()
                        23
            """)
        assert actual == target, \
            systemtools.TestManager.diff(actual, target, 'Diff:')
def test_documentationtools_GraphvizGraph_pickle_01():
    graph = documentationtools.GraphvizGraph()
    assert str(graph) == stringtools.normalize(r'''
        digraph G {
        }
        ''')
    pickled = pickle.loads(pickle.dumps(graph))
    assert str(graph) == str(pickled)
def test_documentationtools_GraphvizGraph_deepcopy_01():
    graph = documentationtools.GraphvizGraph()
    assert str(graph) == stringtools.normalize(r'''
        digraph G {
        }
        ''')
    copied = copy.deepcopy(graph)
    assert str(graph) == str(copied)
Esempio n. 55
0
    def test_4(self):
        source = textwrap.dedent('''
        ..  abjad::
            :stylesheet: non-proportional.ly

            show(Note("c'4"))
        ''')
        document = self.handler.parse_rst(source)
        result = stringtools.normalize(document.pformat())
        expected = stringtools.normalize(
            r'''
            <document source="test">
                <abjad_input_block stylesheet="non-proportional.ly">
                    <literal_block xml:space="preserve">
                        show(Note("c'4"))
            ''')
        self.assertEqual(result, expected)
Esempio n. 56
0
    def test_6(self):
        source = textwrap.dedent('''
        ..  abjad::
            :text-width: 80
            :with-columns: 2

            show(Note("c'4"))
        ''')
        document = self.handler.parse_rst(source)
        result = stringtools.normalize(document.pformat())
        expected = stringtools.normalize(r'''
            <document source="test">
                <abjad_input_block text-width="80" with-columns="2">
                    <literal_block xml:space="preserve">
                        show(Note("c'4"))
            ''')
        self.assertEqual(result, expected)
    def test_abjadextract_3(self):
        input_file_contents = [
            '\\begin{comment}',
            '<abjadextract abjad.tools.abjadbooktools:example_function \>[hide=true]',
            '\\end{comment}',
            '',
            '\\begin{comment}',
            '<abjad>[allow_exceptions=true]',
            "example_function('foo')",
            '</abjad>',
            '\\end{comment}',
            '',
            '\\begin{comment}',
            '<abjad>[allow_exceptions=true]',
            "example_function(23)",
            '</abjad>',
            '\\end{comment}',
        ]
        document_handler = abjadbooktools.LaTeXDocumentHandler(
            input_file_contents=input_file_contents, )
        rebuilt_source = document_handler(return_source=True)
        assert rebuilt_source == stringtools.normalize(
            """
            \\begin{comment}
            <abjadextract abjad.tools.abjadbooktools:example_function \\>[hide=true]
            \\end{comment}

            \\begin{comment}
            <abjad>[allow_exceptions=true]
            example_function('foo')
            </abjad>
            \\end{comment}

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            >>> example_function('foo')
            Entering example function.
            Wrong type!
            foo
            Leaving example function.
            \\end{lstlisting}
            %%% ABJADBOOK END %%%

            \\begin{comment}
            <abjad>[allow_exceptions=true]
            example_function(23)
            </abjad>
            \\end{comment}

            %%% ABJADBOOK START %%%
            \\begin{lstlisting}
            >>> example_function(23)
            Entering example function.
            24
            Leaving example function.
            \\end{lstlisting}
            %%% ABJADBOOK END %%%
            """, )
    def test_lilypond_error(self):
        """
        Handle failing LilyPond rendering.
        """
        self.create_score()
        material_path = self.create_material('test_material')
        definition_path = material_path.joinpath('definition.py')
        with open(str(definition_path), 'w') as file_pointer:
            file_pointer.write(stringtools.normalize(r'''
            # -*- coding: utf-8 -*-
            from abjad.tools import lilypondfiletools


            test_material = lilypondfiletools.make_basic_lilypond_file()
            test_material.items.append(r'\this-does-not-exist')
            '''))
        script = commandlinetools.ManageMaterialScript()
        command = ['--illustrate', 'test_material']
        with systemtools.RedirectedStreams(stdout=self.string_io):
            with systemtools.TemporaryDirectoryChange(str(self.score_path)):
                with self.assertRaises(SystemExit) as context_manager:
                    script(command)
                assert context_manager.exception.code == 1
        self.compare_captured_output(r'''
            Illustration candidates: 'test_material' ...
            Illustrating test_score/materials/test_material/
                Importing test_score.materials.test_material.definition
                    Abjad runtime: ... second...
                Writing test_score/materials/test_material/illustration.ly ... OK!
                Writing test_score/materials/test_material/illustration.pdf ... Failed!
        '''.replace('/', os.path.sep))
        illustration_ly_path = material_path.joinpath('illustration.ly')
        assert illustration_ly_path.exists()
        self.compare_lilypond_contents(
            illustration_ly_path, stringtools.normalize(r'''
            \language "english"

            \header {}

            \layout {}

            \paper {}

            \this-does-not-exist
            '''))
    def test_on_doctree_read_07(self):
        source = '''
        ..  abjad::
            :hide:
            :no-trim:
            :pages: 1-4
            :with-columns: 2

            show(Staff("c'4 d'4 e'4 f'4"))
        '''
        handler = abjadbooktools.SphinxDocumentHandler()
        document = handler.parse_rst(source)
        handler.on_doctree_read(self.app, document)
        actual = stringtools.normalize(document.pformat())
        target = stringtools.normalize(
            r"""
            <document source="test">
                <block_quote>
                    <abjad_output_block image_layout_specifier="ImageLayoutSpecifier(pages=(1, 2, 3, 4), with_columns=2)" image_render_specifier="ImageRenderSpecifier(no_trim=True, stylesheet='default.ly')" renderer="lilypond" xml:space="preserve">
                        \version "2.19.0"
                        \language "english"

                        #(ly:set-option 'relative-includes #t)

                        \include "default.ly"

                        \header {
                            tagline = \markup {}
                        }

                        \layout {}

                        \paper {}

                        \score {
                            \new Staff {
                                c'4
                                d'4
                                e'4
                                f'4
                            }
                        }
            """)
        assert actual == target, \
            systemtools.TestManager.diff(actual, target, 'Diff:')