File: test_filter.py

package info (click to toggle)
sphinxcontrib-bibtex 2.6.5-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,140 kB
  • sloc: python: 4,668; makefile: 245
file content (71 lines) | stat: -rw-r--r-- 2,531 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import pytest


@pytest.mark.sphinx("html", testroot="filter")
def test_filter(app, warning) -> None:
    app.build()
    assert not warning.getvalue()
    output = (app.outdir / "index.html").read_text()
    assert "Tralalala" in output
    assert "ideetje" not in output
    assert "Jakkamakka" not in output
    output = (app.outdir / "or.html").read_text()
    assert "Tralalala" not in output
    assert "ideetje" in output
    assert "Jakkamakka" in output
    output = (app.outdir / "noteq.html").read_text()
    assert "Tralalala" in output
    assert "ideetje" in output
    assert "Jakkamakka" not in output
    output = (app.outdir / "lt.html").read_text()
    assert "Tralalala" in output
    assert "ideetje" not in output
    assert "Jakkamakka" not in output
    output = (app.outdir / "lte.html").read_text()
    assert "Tralalala" in output
    assert "ideetje" not in output
    assert "Jakkamakka" in output
    output = (app.outdir / "gt.html").read_text()
    assert "Tralalala" not in output
    assert "ideetje" in output
    assert "Jakkamakka" not in output
    output = (app.outdir / "gte.html").read_text()
    assert "Tralalala" not in output
    assert "ideetje" in output
    assert "Jakkamakka" in output
    output = (app.outdir / "key.html").read_text()
    assert "Tralalala" not in output
    assert "ideetje" in output
    assert "Jakkamakka" not in output
    output = (app.outdir / "false.html").read_text()
    assert "Tralalala" not in output
    assert "ideetje" not in output
    assert "Jakkamakka" not in output
    output = (app.outdir / "true.html").read_text()
    assert "Tralalala" in output
    assert "ideetje" in output
    assert "Jakkamakka" in output
    output = (app.outdir / "title.html").read_text()
    assert "Tralalala" not in output
    assert "ideetje" not in output
    assert "Jakkamakka" in output


@pytest.mark.sphinx("html", testroot="filter_fix_author_keyerror")
def test_filter_fix_author_keyerror(app) -> None:
    app.build()


@pytest.mark.sphinx("html", testroot="filter_option_clash")
def test_filter_option_clash(app, warning) -> None:
    app.build()
    warnings = warning.getvalue()
    assert ":filter: overrides :all:" in warnings
    assert ":filter: overrides :cited:" in warnings
    assert ":filter: overrides :notcited:" in warnings


@pytest.mark.sphinx("html", testroot="filter_syntax_error")
def test_filter_syntax_error(app, warning) -> None:
    app.build()
    assert warning.getvalue().count("syntax error in :filter: expression") == 9