Skip to content

Commit

Permalink
ci: fix tests in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
gaige committed Jun 29, 2024
1 parent 7446dc7 commit 8e74013
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
17 changes: 3 additions & 14 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Installation (deps and package)
# we install with flit --pth-file,
# so that coverage will be recorded for the module
run: |
pip install flit
flit install --deps=production --extras=test --pth-file
- name: Run pytest
run: |
pytest --cov=mdformat_pelican --cov-report=xml --cov-report=term-missing
- name: Run pytest with mdformat-gfm
- name: Run tox in this environment
run: |
pip install mdformat-gfm
pytest --cov=mdformat_pelican --cov-report=xml --cov-report=term-missing
python -m pip install tox
tox
pre-commit-hook:
runs-on: ubuntu-latest
Expand Down
4 changes: 1 addition & 3 deletions mdformat_pelican/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ def _pelican_link_open_renderer(node: RenderTreeNode, context: RenderContext) ->

def _patch_gfm_link_renderer(node: RenderTreeNode, context: RenderContext) -> str:
"""Patched link renderer that replaces pelican placeholders in link's href."""
if any(
(bad_placeholder in node.attrs["href"]) for bad_placeholder in PLACEHOLDERS
):
if any((bad_placeholder in node.attrs["href"]) for bad_placeholder in PLACEHOLDERS):
node.attrs["href"] = replace_pelican_placeholdlers(node.attrs["href"])
# Use the original renderer.
return mdformat_gfm.plugin._link_renderer(node, context)
Expand Down
7 changes: 4 additions & 3 deletions tests/test_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pathlib import Path
import sys

from markdown_it.utils import read_fixture_file
import mdformat
import pytest
import sys

have_gfm = 'mdformat_gfm' in sys.modules
have_gfm = "mdformat_gfm" in sys.modules

FIXTURE_PATH = Path(__file__).parent / "fixtures.md"
fixtures = read_fixture_file(FIXTURE_PATH)
Expand All @@ -18,9 +18,10 @@ def test_fixtures(line, title, text, expected):
print(output)
assert output.rstrip() == expected.rstrip(), output


@pytest.mark.skipif(not have_gfm, reason="testing without gfm")
@pytest.mark.parametrize("line,title,text,expected", fixtures, ids=[f[1] for f in fixtures])
def test_fixtures_gfm(line, title, text, expected):
output = mdformat.text(text, extensions={"pelican","gfm"})
output = mdformat.text(text, extensions={"gfm", "pelican"})
print(output)
assert output.rstrip() == expected.rstrip(), output
8 changes: 2 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ isolated_build = True

[testenv:py{38,39,310,311,312}]
extras = test
commands = pytest {posargs}
commands = pytest --cov --cov-append --cov-report=term-missing {posargs}

[testenv:py{38,39,310,311,312}-gfm]
deps = mdformat_gfm
extras = test
commands = pytest {posargs}

[testenv:py{38,39,310,311,312}-cov]
extras = test
commands = pytest --cov={envsitepackagesdir}/mdformat_pelican {posargs}
commands = pytest --cov --cov-append --cov-report=term-missing {posargs}

# 3.12 is left out beause of issues with importlib_metadata.entry_points
[testenv:py{38,39,310,311}-pre-commit]
Expand Down

0 comments on commit 8e74013

Please sign in to comment.