Skip to content

Commit ade8d9c

Browse files
authored
🧪 TESTS: Add testing for Python 3.9 and pygments versions (#135)
* Include testing for python 3.9 * Remove pygments output from regression test HTML * Add pygments version paramtrization to Actions CI * Change CI sphinx version from pre-release * Add new regression outputs for Sphinx 4 * Change test to use independent root
1 parent 0f185f4 commit ade8d9c

19 files changed

+1355
-207
lines changed

‎.github/workflows/tests.yml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ jobs:
1717
runs-on: ubuntu-latest
1818
strategy:
1919
matrix:
20-
python-version: [3.6, 3.7, 3.8]
21-
sphinx: [">=2,<3", ">=3,<4", "==4.0.0b1"]
20+
python-version: [3.6, 3.7, 3.8, 3.9]
21+
sphinx: [">=2,<3", ">=3,<4", ">=4,<5"]
22+
pygments: ["==2.8.0", "==2.9.0", "==2.10.0"]
2223

2324
steps:
2425
- uses: actions/checkout@v2
@@ -30,6 +31,7 @@ jobs:
3031
run: |
3132
python -m pip install --upgrade pip
3233
pip install "sphinx${{ matrix.sphinx }}"
34+
pip install "pygments${{ matrix.pygments }}"
3335
pip install .[testing]
3436
- name: Run pytest
3537
run: |

‎tests/conftest.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,19 @@ def regress_sphinx_app_output(file_regression, get_sphinx_app_output):
7575
non-deterministic).
7676
"""
7777

78-
def read(
79-
app, buildername="html", filename="index.html", encoding="utf-8", replace=None
80-
):
78+
def read(app, buildername="html", filename="index.html", encoding="utf-8"):
8179
content = get_sphinx_app_output(app, buildername, filename, encoding)
8280

8381
if buildername == "html":
8482
soup = BeautifulSoup(content, "html.parser")
83+
84+
# Remove output from ``pygments``, so that test only compares HTML of surrounding tabs
85+
for div in soup.find_all("div", {"class": "highlight"}):
86+
div.decompose()
87+
8588
doc_div = soup.findAll("div", {"class": "documentwrapper"})[0]
8689
doc = doc_div.prettify()
87-
for find, rep in (replace or {}).items():
88-
doc = text.replace(find, rep)
90+
8991
else:
9092
doc = content
9193
file_regression.check(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project = "sphinx-tabs test"
2+
master_doc = "index"
3+
source_suffix = ".rst"
4+
extensions = ["sphinx_tabs.tabs"]
5+
pygments_style = "sphinx"
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
.. toctree::
2+
3+
no_tabs1
4+
no_tabs2
5+
6+
Fruits
7+
========================================
8+
9+
.. tabs::
10+
11+
.. tab:: Apples
12+
13+
Apples are green, or sometimes red.
14+
15+
.. tab:: Pears
16+
17+
Pears are green.
18+
19+
.. tab:: Oranges
20+
21+
Oranges are orange.
22+
23+
Luminaries
24+
========================================
25+
26+
.. tabs::
27+
28+
.. tab:: Sun
29+
30+
The sun is a star.
31+
32+
.. tab:: Moon
33+
34+
The moon is not a star.
35+
36+
Code Tabs
37+
========================================
38+
39+
.. tabs::
40+
41+
.. code-tab:: c
42+
43+
C Main Function
44+
45+
.. code-tab:: c++
46+
47+
C++ Main Function
48+
49+
.. code-tab:: py
50+
51+
Python Main Function
52+
53+
.. code-tab:: java
54+
55+
Java Main Function
56+
57+
.. code-tab:: julia
58+
59+
Julia Main Function
60+
61+
.. code-tab:: fortran
62+
63+
Fortran Main Function
64+
65+
.. tabs::
66+
67+
.. code-tab:: c
68+
69+
int main(const int argc, const char **argv) {
70+
return 0;
71+
}
72+
73+
.. code-tab:: c++
74+
75+
int main(const int argc, const char **argv) {
76+
return 0;
77+
}
78+
79+
.. code-tab:: py
80+
81+
def main():
82+
return
83+
84+
.. code-tab:: java
85+
86+
class Main {
87+
public static void main(String[] args) {
88+
}
89+
}
90+
91+
.. code-tab:: julia
92+
93+
function main()
94+
end
95+
96+
.. code-tab:: fortran
97+
98+
PROGRAM main
99+
END PROGRAM main
100+
101+
Group Tabs
102+
========================================
103+
104+
.. tabs::
105+
106+
.. group-tab:: Linux
107+
108+
Linux Line 1
109+
110+
.. group-tab:: Mac OSX
111+
112+
Mac OSX Line 1
113+
114+
.. group-tab:: Windows
115+
116+
Windows Line 1
117+
118+
.. tabs::
119+
120+
.. group-tab:: Linux
121+
122+
Linux Line 2
123+
124+
.. group-tab:: Mac OSX
125+
126+
Mac OSX Line 2
127+
128+
.. group-tab:: Windows
129+
130+
Windows Line 2
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Another page without tabs
2+
========================================
3+
4+
No tabs to see here
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
And another page without tabs
2+
========================================
3+
4+
No tabs to see here either

‎tests/test_build.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_conditional_assets(app, docname, check_asset_links):
2727

2828
@pytest.mark.noautobuild
2929
@pytest.mark.parametrize("docname", ["index", "no_tabs1", "no_tabs2"])
30-
@pytest.mark.sphinx(testroot="conditionalassets")
30+
@pytest.mark.sphinx(testroot="conditionalassets-policy")
3131
@pytest.mark.skipif(
3232
sphinx.version_info[:2] < (4, 1), reason="Test uses Sphinx 4.1 config"
3333
)

0 commit comments

Comments
 (0)