Skip to content

Commit

Permalink
test(#23): add red test
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing committed Apr 14, 2024
1 parent 00c458e commit cd74c24
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/format/fixtures/content_tabs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Do not modify multi-line code from: https://github.com/KyleKing/mdformat-mkdocs/issues/23
.
=== "duty"
```python title="duties.py"
@duty(silent=True)
def coverage(ctx):
ctx.run("coverage combine", nofail=True)
ctx.run("coverage report --rcfile=config/coverage.ini", capture=False)
ctx.run("coverage html --rcfile=config/coverage.ini")


@duty
def test(ctx, match: str = ""):
py_version = f"{sys.version_info.major}{sys.version_info.minor}"
os.environ["COVERAGE_FILE"] = f".coverage.{py_version}"
ctx.run(
["pytest", "-c", "config/pytest.ini", "-n", "auto", "-k", match, "tests"],
title="Running tests",
)
```
.
=== "duty"
```python title="duties.py"
@duty(silent=True)
def coverage(ctx):
ctx.run("coverage combine", nofail=True)
ctx.run("coverage report --rcfile=config/coverage.ini", capture=False)
ctx.run("coverage html --rcfile=config/coverage.ini")


@duty
def test(ctx, match: str = ""):
py_version = f"{sys.version_info.major}{sys.version_info.minor}"
os.environ["COVERAGE_FILE"] = f".coverage.{py_version}"
ctx.run(
["pytest", "-c", "config/pytest.ini", "-n", "auto", "-k", match, "tests"],
title="Running tests",
)
```
.
21 changes: 21 additions & 0 deletions tests/format/test_content_tabs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from pathlib import Path

import mdformat
import pytest
from markdown_it.utils import read_fixture_file

from ..helpers import print_text

FIXTURE_PATH = Path(__file__).parent / "fixtures/content_tabs.md"
fixtures = read_fixture_file(FIXTURE_PATH)


@pytest.mark.parametrize(
("line", "title", "text", "expected"),
fixtures,
ids=[f[1] for f in fixtures],
)
def test_content_tabs_fixtures(line, title, text, expected):
output = mdformat.text(text, extensions={"mkdocs", "admonition"})
print_text(output, expected)
assert output.rstrip() == expected.rstrip()

0 comments on commit cd74c24

Please sign in to comment.