Example #1
0
def test_nbconv_file_contents(tmp_path: Path):
    """Run ``nbconv`` with the ``exporter`` or ``out_file`` argument."""
    nb = make_notebook(tmp_path)
    assert nbconv(in_file=nb, exporter="html")[1].startswith("<!DOCTYPE html>")
    assert nbconv(in_file=nb, out_file="o.html")[1].startswith("<!DOCTYPE html")
    assert nbconv(in_file=nb, out_file="o.___")[1].startswith("<!DOCTYPE html>")
    assert nbconv(in_file=nb, out_file="o.asc")[1].startswith("\n[[background]")
    assert nbconv(in_file=nb, exporter="rst")[1].startswith("\nBackground\n")
    assert nbconv(in_file=nb, out_file="o.rst")[1].startswith("\nBackground\n")
Example #2
0
def test_nbconv(exporters, tmp_path: Path) -> None:
    """Convert ``tempfiles`` with each exporter in ``exporters``."""
    nb = make_temp_notebook(tmp_path)
    assert nbconv(in_file=nb, exporter=exporters)[0].endswith("." + exporters)
Example #3
0
def test_raises(not_exporters, tmp_path: Path) -> None:
    """Make sure a ValueError is raised if nbconv() gets a bad exporter."""
    nb = make_temp_notebook(tmp_path)
    with pytest.raises(ValueError):
        nbconv(in_file=nb, exporter=not_exporters)
Example #4
0
def test_nbconv(exporters, tmp_path: Path) -> None:
    """Convert a temporary notebook with each exporter in ``exporters``."""
    nb = make_notebook(tmp_path)
    assert nbconv(in_file=nb, exporter=exporters)[0].endswith("." + exporters)
    assert nbconv(in_file=nb)[0].endswith(".html")
Example #5
0
def test_raises(not_exporters, tmp_path: Path) -> None:
    """Make sure a ``ValueError`` is raised if ``nbconv`` gets a bad exporter."""
    nb = make_notebook(tmp_path)
    with pytest.raises(ValueError):
        nbconv(in_file=nb, exporter=not_exporters)
        nbconv(in_file=nb, out_file="out." + not_exporters)