Example #1
0
def test_mpl_interactive():
    page = """\
Text here

.. mpl-interactive::

More text here."""
    pxml = to_pxml.from_rst(page)
    assert re.match(
        """\
<document source=".*?">
    <paragraph>
        Text here
    <mpl_hint>
        <paragraph>
            If running in the IPython console, consider running 
            <literal>
                %matplotlib
             to enable
            interactive plots.  If running in the Jupyter Notebook, use 
            <literal>
                %matplotlib
                inline
            .
    <paragraph>
        More text here.""", pxml)
    page = """\
Text here

.. mpl-interactive::

    Any ReST you *like*.

More text here."""
    pxml = to_pxml.from_rst(page)
    assert re.match(
        """\
<document source=".*?">
    <paragraph>
        Text here
    <mpl_hint>
        <paragraph>
            Any ReST you 
            <emphasis>
                like
            .
    <paragraph>
        More text here.""", pxml)
 def assert_rst_pxml(pxml_params, rst_source):
     code_type = pxml_params['code_type']
     pxml = to_pxml.from_rst(rst_source)
     if not 'ext' in pxml_params:
         pxml_params['ext'] = 'py' if code_type == 'pyfile' else 'ipynb'
     pxml_regex = expected_re_fmt.format(role_type=code_type, **pxml_params)
     assert re.match(pxml_regex, pxml)
 def as_pxml(rst_text):
     return to_pxml.from_rst(rst_text, resolve=False)