From 0f185f426caad91c2cd18229ca3d458b858b396e Mon Sep 17 00:00:00 2001
From: Karolina Surma <33810531+befeleme@users.noreply.github.com>
Date: Thu, 5 Aug 2021 19:17:16 +0200
Subject: [PATCH 1/7] Fix test_other_with_assets_new_style w/Sphinx 4.0 (#133)
Make the test work with Sphinx 4.0.x.
Fix the typo so that the regression file is actually found.
---
tests/test_build.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/test_build.py b/tests/test_build.py
index ee01aa9..37a63bd 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -64,9 +64,9 @@ def test_other_with_assets(app, check_asset_links):
@pytest.mark.sphinx(testroot="linenos")
@pytest.mark.skipif(
- sphinx.version_info[:2] <= (4, 0), reason="Test uses Sphinx 4 code blocks"
+ sphinx.version_info[:2] < (4, 0), reason="Test uses Sphinx 4 code blocks"
)
-def test_other_With_assets_new_style(app, check_asset_links):
+def test_other_with_assets_new_style(app, check_asset_links):
check_asset_links(app)
From ade8d9c1e79cd35187cbb48c5df8cc6b9fc5d43b Mon Sep 17 00:00:00 2001
From: David Foster <31405412+foster999@users.noreply.github.com>
Date: Fri, 20 Aug 2021 12:09:22 +0100
Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=A7=AA=20TESTS:=20Add=20testing=20for?=
=?UTF-8?q?=20Python=203.9=20and=20pygments=20versions=20(#135)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 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
---
.github/workflows/tests.yml | 6 +-
tests/conftest.py | 12 +-
.../test-conditionalassets-policy/conf.py | 5 +
.../test-conditionalassets-policy/index.rst | 130 +++++++++
.../no_tabs1.rst | 4 +
.../no_tabs2.rst | 4 +
tests/test_build.py | 2 +-
...onal_assets_html_assets_policy_index_.html | 248 ++++++++++++++++++
...ional_assets_html_assets_policy_index_.xml | 152 +++++++++++
...l_assets_html_assets_policy_no_tabs1_.html | 248 ++++++++++++++++++
...al_assets_html_assets_policy_no_tabs1_.xml | 152 +++++++++++
...l_assets_html_assets_policy_no_tabs2_.html | 248 ++++++++++++++++++
...al_assets_html_assets_policy_no_tabs2_.xml | 152 +++++++++++
.../test_conditional_assets_index_.html | 58 ----
.../test_conditional_assets_no_tabs1_.html | 58 ----
.../test_conditional_assets_no_tabs2_.html | 58 ----
tests/test_build/test_custom_lexer.html | 9 -
tests/test_build/test_other_with_assets.html | 8 -
.../test_other_with_assets_new_style.html | 8 -
19 files changed, 1355 insertions(+), 207 deletions(-)
create mode 100644 tests/roots/test-conditionalassets-policy/conf.py
create mode 100644 tests/roots/test-conditionalassets-policy/index.rst
create mode 100644 tests/roots/test-conditionalassets-policy/no_tabs1.rst
create mode 100644 tests/roots/test-conditionalassets-policy/no_tabs2.rst
create mode 100644 tests/test_build/test_conditional_assets_html_assets_policy_index_.html
create mode 100644 tests/test_build/test_conditional_assets_html_assets_policy_index_.xml
create mode 100644 tests/test_build/test_conditional_assets_html_assets_policy_no_tabs1_.html
create mode 100644 tests/test_build/test_conditional_assets_html_assets_policy_no_tabs1_.xml
create mode 100644 tests/test_build/test_conditional_assets_html_assets_policy_no_tabs2_.html
create mode 100644 tests/test_build/test_conditional_assets_html_assets_policy_no_tabs2_.xml
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index c0767a3..b7414e8 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -17,8 +17,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- python-version: [3.6, 3.7, 3.8]
- sphinx: [">=2,<3", ">=3,<4", "==4.0.0b1"]
+ python-version: [3.6, 3.7, 3.8, 3.9]
+ sphinx: [">=2,<3", ">=3,<4", ">=4,<5"]
+ pygments: ["==2.8.0", "==2.9.0", "==2.10.0"]
steps:
- uses: actions/checkout@v2
@@ -30,6 +31,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install "sphinx${{ matrix.sphinx }}"
+ pip install "pygments${{ matrix.pygments }}"
pip install .[testing]
- name: Run pytest
run: |
diff --git a/tests/conftest.py b/tests/conftest.py
index aea4aa0..6c15bd4 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -75,17 +75,19 @@ def regress_sphinx_app_output(file_regression, get_sphinx_app_output):
non-deterministic).
"""
- def read(
- app, buildername="html", filename="index.html", encoding="utf-8", replace=None
- ):
+ def read(app, buildername="html", filename="index.html", encoding="utf-8"):
content = get_sphinx_app_output(app, buildername, filename, encoding)
if buildername == "html":
soup = BeautifulSoup(content, "html.parser")
+
+ # Remove output from ``pygments``, so that test only compares HTML of surrounding tabs
+ for div in soup.find_all("div", {"class": "highlight"}):
+ div.decompose()
+
doc_div = soup.findAll("div", {"class": "documentwrapper"})[0]
doc = doc_div.prettify()
- for find, rep in (replace or {}).items():
- doc = text.replace(find, rep)
+
else:
doc = content
file_regression.check(
diff --git a/tests/roots/test-conditionalassets-policy/conf.py b/tests/roots/test-conditionalassets-policy/conf.py
new file mode 100644
index 0000000..1fc6dcb
--- /dev/null
+++ b/tests/roots/test-conditionalassets-policy/conf.py
@@ -0,0 +1,5 @@
+project = "sphinx-tabs test"
+master_doc = "index"
+source_suffix = ".rst"
+extensions = ["sphinx_tabs.tabs"]
+pygments_style = "sphinx"
diff --git a/tests/roots/test-conditionalassets-policy/index.rst b/tests/roots/test-conditionalassets-policy/index.rst
new file mode 100644
index 0000000..1d1ec6e
--- /dev/null
+++ b/tests/roots/test-conditionalassets-policy/index.rst
@@ -0,0 +1,130 @@
+.. toctree::
+
+ no_tabs1
+ no_tabs2
+
+Fruits
+========================================
+
+.. tabs::
+
+ .. tab:: Apples
+
+ Apples are green, or sometimes red.
+
+ .. tab:: Pears
+
+ Pears are green.
+
+ .. tab:: Oranges
+
+ Oranges are orange.
+
+Luminaries
+========================================
+
+.. tabs::
+
+ .. tab:: Sun
+
+ The sun is a star.
+
+ .. tab:: Moon
+
+ The moon is not a star.
+
+Code Tabs
+========================================
+
+.. tabs::
+
+ .. code-tab:: c
+
+ C Main Function
+
+ .. code-tab:: c++
+
+ C++ Main Function
+
+ .. code-tab:: py
+
+ Python Main Function
+
+ .. code-tab:: java
+
+ Java Main Function
+
+ .. code-tab:: julia
+
+ Julia Main Function
+
+ .. code-tab:: fortran
+
+ Fortran Main Function
+
+.. tabs::
+
+ .. code-tab:: c
+
+ int main(const int argc, const char **argv) {
+ return 0;
+ }
+
+ .. code-tab:: c++
+
+ int main(const int argc, const char **argv) {
+ return 0;
+ }
+
+ .. code-tab:: py
+
+ def main():
+ return
+
+ .. code-tab:: java
+
+ class Main {
+ public static void main(String[] args) {
+ }
+ }
+
+ .. code-tab:: julia
+
+ function main()
+ end
+
+ .. code-tab:: fortran
+
+ PROGRAM main
+ END PROGRAM main
+
+Group Tabs
+========================================
+
+.. tabs::
+
+ .. group-tab:: Linux
+
+ Linux Line 1
+
+ .. group-tab:: Mac OSX
+
+ Mac OSX Line 1
+
+ .. group-tab:: Windows
+
+ Windows Line 1
+
+.. tabs::
+
+ .. group-tab:: Linux
+
+ Linux Line 2
+
+ .. group-tab:: Mac OSX
+
+ Mac OSX Line 2
+
+ .. group-tab:: Windows
+
+ Windows Line 2
diff --git a/tests/roots/test-conditionalassets-policy/no_tabs1.rst b/tests/roots/test-conditionalassets-policy/no_tabs1.rst
new file mode 100644
index 0000000..291ccfa
--- /dev/null
+++ b/tests/roots/test-conditionalassets-policy/no_tabs1.rst
@@ -0,0 +1,4 @@
+Another page without tabs
+========================================
+
+No tabs to see here
diff --git a/tests/roots/test-conditionalassets-policy/no_tabs2.rst b/tests/roots/test-conditionalassets-policy/no_tabs2.rst
new file mode 100644
index 0000000..99ef57d
--- /dev/null
+++ b/tests/roots/test-conditionalassets-policy/no_tabs2.rst
@@ -0,0 +1,4 @@
+And another page without tabs
+========================================
+
+No tabs to see here either
diff --git a/tests/test_build.py b/tests/test_build.py
index 37a63bd..a44a9ef 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -27,7 +27,7 @@ def test_conditional_assets(app, docname, check_asset_links):
@pytest.mark.noautobuild
@pytest.mark.parametrize("docname", ["index", "no_tabs1", "no_tabs2"])
-@pytest.mark.sphinx(testroot="conditionalassets")
+@pytest.mark.sphinx(testroot="conditionalassets-policy")
@pytest.mark.skipif(
sphinx.version_info[:2] < (4, 1), reason="Test uses Sphinx 4.1 config"
)
diff --git a/tests/test_build/test_conditional_assets_html_assets_policy_index_.html b/tests/test_build/test_conditional_assets_html_assets_policy_index_.html
new file mode 100644
index 0000000..c9ba110
--- /dev/null
+++ b/tests/test_build/test_conditional_assets_html_assets_policy_index_.html
@@ -0,0 +1,248 @@
+
+
+
+
+
+
+ Fruits
+
+
+
+
+
+
+
+
+
+
+ Apples are green, or sometimes red.
+
+
+
+
+
+ Oranges are orange.
+
+
+
+
+
+
+ Luminaries
+
+
+
+
+
+
+
+
+
+ The sun is a star.
+
+
+
+
+ The moon is not a star.
+
+
+
+
+
+
+ Code Tabs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Group Tabs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/test_build/test_conditional_assets_html_assets_policy_index_.xml b/tests/test_build/test_conditional_assets_html_assets_policy_index_.xml
new file mode 100644
index 0000000..7fe4f8f
--- /dev/null
+++ b/tests/test_build/test_conditional_assets_html_assets_policy_index_.xml
@@ -0,0 +1,152 @@
+
+
+
+
+
+ Fruits
+
+
+