Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🧪 TESTS: Add testing for Python 3.9 and pygments versions #135

Merged
merged 6 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: |
Expand Down
12 changes: 7 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions tests/roots/test-conditionalassets-policy/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project = "sphinx-tabs test"
master_doc = "index"
source_suffix = ".rst"
extensions = ["sphinx_tabs.tabs"]
pygments_style = "sphinx"
130 changes: 130 additions & 0 deletions tests/roots/test-conditionalassets-policy/index.rst
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/roots/test-conditionalassets-policy/no_tabs1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Another page without tabs
========================================

No tabs to see here
4 changes: 4 additions & 0 deletions tests/roots/test-conditionalassets-policy/no_tabs2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
And another page without tabs
========================================

No tabs to see here either
2 changes: 1 addition & 1 deletion tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Loading