chrisjsewell / ipypublish
1
# -*- coding: utf-8 -*-
2 3
"""
3
    test_sphinx
4
    ~~~~~~~~~~~
5

6
    General Sphinx test and check output.
7
"""
8 3
import pytest
9 3
import sphinx
10

11 3
from ipypublish.sphinx.tests import get_test_source_dir
12

13 3
from ipypublish.tests.utils import HTML2JSONParser
14

15

16 3
@pytest.mark.sphinx(buildername="html", srcdir=get_test_source_dir("notebook"))
17 3
def test_basic(app, status, warning, get_sphinx_app_output, data_regression):
18

19 3
    app.build()
20

21 3
    assert "build succeeded" in status.getvalue()  # Build succeeded
22 3
    warnings = warning.getvalue().strip()
23 3
    assert warnings == ""
24

25 3
    output = get_sphinx_app_output(app, buildername="html")
26

27 3
    parser = HTML2JSONParser()
28 3
    parser.feed(output)
29 3
    if sphinx.version_info >= (2,):
30 3
        data_regression.check(parser.parsed, basename="test_basic_v2")
31
    else:
32 0
        data_regression.check(parser.parsed, basename="test_basic_v1")
33

34

35 3
@pytest.mark.sphinx(
36
    buildername="html", srcdir=get_test_source_dir("notebook_cell_decor")
37
)
38 3
def test_cell_decoration(app, status, warning, get_sphinx_app_output, data_regression):
39
    """ test a notebook with prompts and toggle buttons"""
40 3
    app.build()
41

42 3
    assert "build succeeded" in status.getvalue()  # Build succeeded
43 3
    warnings = warning.getvalue().strip()
44 3
    assert warnings == ""
45

46 3
    output = get_sphinx_app_output(app, buildername="html")
47

48 3
    parser = HTML2JSONParser()
49 3
    parser.feed(output)
50 3
    if sphinx.version_info >= (2,):
51 3
        data_regression.check(parser.parsed, basename="test_cell_decoration_v2")
52
    else:
53 0
        data_regression.check(parser.parsed, basename="test_cell_decoration_v1")
54

55

56 3
@pytest.mark.sphinx(
57
    buildername="html", srcdir=get_test_source_dir("notebook_ipywidget")
58
)
59 3
def test_ipywidget(app, status, warning, get_sphinx_app_output, data_regression):
60
    """ test which contains an ipywidgets and the widget state has been saved."""
61 3
    app.build()
62

63 3
    assert "build succeeded" in status.getvalue()  # Build succeeded
64 3
    warnings = warning.getvalue().strip()
65 3
    assert warnings == ""
66

67 3
    output = get_sphinx_app_output(app, buildername="html")
68

69 3
    parser = HTML2JSONParser()
70 3
    parser.feed(output)
71 3
    data_regression.check(parser.parsed, basename="test_ipywidget")

Read our documentation on viewing source code .

Loading