Skip to content

Commit

Permalink
Add a test for view-annotate=displayhtml
Browse files Browse the repository at this point in the history
  • Loading branch information
user202729 committed Dec 12, 2024
1 parent 0c152a1 commit 0447579
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/sage/repl/ipython_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ def cython(self, line, cell):
This is syntactic sugar on the
:func:`~sage.misc.cython.cython_compile` function.
Note that there is also the ``%%cython`` cell magic provided by Cython,
which can be loaded with ``%load_ext cython``, see
`Cython documentation <https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiling-with-a-jupyter-notebook>`_
for more details.
The semantic is slightly different from the version provided by Sage.
INPUT:
- ``line`` -- parsed as keyword arguments. The allowed arguments are:
Expand Down Expand Up @@ -425,6 +431,36 @@ def cython(self, line, cell):
....: ''')
UsageError: argument --view-annotate: invalid choice: 'xx' (choose from 'none', 'auto', 'webbrowser', 'displayhtml')
Test ``--view-annotate=displayhtml`` (note that in a notebook environment
an inline HTML frame will be displayed)::
sage: # needs sage.misc.cython
sage: shell.run_cell('''
....: %%cython --view-annotate=displayhtml
....: print(1)
....: ''')
1
<IPython.core.display.HTML object>
Test ``--view-annotate=webbrowser``::
sage: # needs sage.misc.cython webbrowser
sage: shell.run_cell('''
....: %%cython --view-annotate
....: print(1)
....: ''')
1
sage: shell.run_cell('''
....: %%cython --view-annotate=auto
....: print(1)
....: ''')
1
sage: shell.run_cell('''
....: %%cython --view-annotate=webbrowser
....: print(1)
....: ''')
1
Test invalid quotes (see :mod:`sage.repl.interpreter` for explanation of the dummy line)::
sage: # needs sage.misc.cython
Expand Down

0 comments on commit 0447579

Please sign in to comment.