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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃И TESTS: Update pytest-param-files #500

Merged
merged 4 commits into from Jan 9, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Expand Up @@ -84,7 +84,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install .
pip install pytest~=6.2 pytest-param-files~=0.2.2 docutils==${{ matrix.docutils-version }}
pip install pytest~=6.2 pytest-param-files~=0.3.3 docutils==${{ matrix.docutils-version }}
- name: ensure sphinx is not installed
run: |
python -c "\
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -79,7 +79,7 @@ testing =
pytest>=6,<7
pytest-cov
pytest-regressions
pytest-param-files~=0.2.2
pytest-param-files~=0.3.3

[flake8]
max-line-length = 100
Expand Down
3 changes: 1 addition & 2 deletions tests/test_html/test_html_to_nodes.py
Expand Up @@ -3,7 +3,6 @@

import pytest
from docutils import nodes
from pytest_param_files import with_parameters

from myst_parser.html_to_nodes import html_to_nodes
from myst_parser.main import MdParserConfig
Expand All @@ -29,7 +28,7 @@ def _run_directive(name: str, first_line: str, content: str, position: int):
)


@with_parameters(FIXTURE_PATH / "html_to_nodes.md")
@pytest.mark.param_file(FIXTURE_PATH / "html_to_nodes.md")
def test_html_to_nodes(file_params, mock_renderer):
output = nodes.container()
output += html_to_nodes(file_params.content, line_number=0, renderer=mock_renderer)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_html/test_parse_html.py
@@ -1,21 +1,21 @@
from pathlib import Path

from pytest_param_files import with_parameters
import pytest

from myst_parser.parse_html import tokenize_html

FIXTURE_PATH = Path(__file__).parent


@with_parameters(FIXTURE_PATH / "html_ast.md")
@pytest.mark.param_file(FIXTURE_PATH / "html_ast.md")
def test_html_ast(file_params):
tokens = "\n".join(
repr(t) for t in tokenize_html(file_params.content).walk(include_self=True)
)
file_params.assert_expected(tokens, rstrip=True)


@with_parameters(FIXTURE_PATH / "html_round_trip.md")
@pytest.mark.param_file(FIXTURE_PATH / "html_round_trip.md")
def test_html_round_trip(file_params):
ast = tokenize_html(file_params.content)
file_params.assert_expected(str(ast), rstrip=True)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_renderers/test_error_reporting.py
Expand Up @@ -2,15 +2,15 @@
from io import StringIO
from pathlib import Path

import pytest
from docutils.core import publish_doctree
from pytest_param_files import with_parameters

from myst_parser.docutils_ import Parser

FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures")


@with_parameters(FIXTURE_PATH / "reporter_warnings.md")
@pytest.mark.param_file(FIXTURE_PATH / "reporter_warnings.md")
def test_basic(file_params):
"""Test basic functionality."""
report_stream = StringIO()
Expand Down
7 changes: 3 additions & 4 deletions tests/test_renderers/test_fixtures_docutils.py
Expand Up @@ -5,15 +5,14 @@
from pathlib import Path

import pytest
from pytest_param_files import with_parameters

from myst_parser.docutils_renderer import DocutilsRenderer, make_document
from myst_parser.main import MdParserConfig, create_md_parser

FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures")


@with_parameters(FIXTURE_PATH / "docutil_syntax_elements.md")
@pytest.mark.param_file(FIXTURE_PATH / "docutil_syntax_elements.md")
def test_syntax_elements(file_params):
parser = create_md_parser(
MdParserConfig(highlight_code_blocks=False), DocutilsRenderer
Expand All @@ -25,7 +24,7 @@ def test_syntax_elements(file_params):
file_params.assert_expected(outcome, rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "docutil_roles.md")
@pytest.mark.param_file(FIXTURE_PATH / "docutil_roles.md")
def test_docutils_roles(file_params):
"""Test output of docutils roles."""
parser = create_md_parser(MdParserConfig(), DocutilsRenderer)
Expand All @@ -34,7 +33,7 @@ def test_docutils_roles(file_params):
file_params.assert_expected(document.pformat(), rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "docutil_directives.md")
@pytest.mark.param_file(FIXTURE_PATH / "docutil_directives.md")
def test_docutils_directives(file_params):
"""Test output of docutils directives."""
if "SKIP" in file_params.description: # line-block directive not yet supported
Expand Down
19 changes: 9 additions & 10 deletions tests/test_renderers/test_fixtures_sphinx.py
Expand Up @@ -7,7 +7,6 @@

import pytest
import sphinx
from pytest_param_files import with_parameters

from myst_parser.main import MdParserConfig, to_docutils
from myst_parser.sphinx_renderer import SphinxRenderer, mock_sphinx_env
Expand All @@ -20,25 +19,25 @@ def test_minimal_sphinx():
assert app.config["author"] == "bob geldof"


@with_parameters(FIXTURE_PATH / "sphinx_syntax_elements.md")
@pytest.mark.param_file(FIXTURE_PATH / "sphinx_syntax_elements.md")
def test_syntax_elements(file_params):
document = to_docutils(file_params.content, in_sphinx_env=True)
file_params.assert_expected(document.pformat(), rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "tables.md")
@pytest.mark.param_file(FIXTURE_PATH / "tables.md")
def test_tables(file_params):
document = to_docutils(file_params.content, in_sphinx_env=True)
file_params.assert_expected(document.pformat(), rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "directive_options.md")
@pytest.mark.param_file(FIXTURE_PATH / "directive_options.md")
def test_directive_options(file_params):
document = to_docutils(file_params.content)
file_params.assert_expected(document.pformat(), rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "sphinx_directives.md")
@pytest.mark.param_file(FIXTURE_PATH / "sphinx_directives.md")
def test_sphinx_directives(file_params):
# TODO fix skipped directives
# TODO test domain directives
Expand All @@ -52,7 +51,7 @@ def test_sphinx_directives(file_params):
file_params.assert_expected(document.pformat(), rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "sphinx_roles.md")
@pytest.mark.param_file(FIXTURE_PATH / "sphinx_roles.md")
def test_sphinx_roles(file_params):
if file_params.title.startswith("SKIP"):
pytest.skip(file_params.title)
Expand All @@ -65,7 +64,7 @@ def test_sphinx_roles(file_params):
file_params.assert_expected(actual, rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "amsmath.md")
@pytest.mark.param_file(FIXTURE_PATH / "amsmath.md")
def test_amsmath(file_params, monkeypatch):
monkeypatch.setattr(SphinxRenderer, "_random_label", lambda self: "mock-uuid")
document = to_docutils(
Expand All @@ -76,7 +75,7 @@ def test_amsmath(file_params, monkeypatch):
file_params.assert_expected(document.pformat(), rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "containers.md")
@pytest.mark.param_file(FIXTURE_PATH / "containers.md")
def test_containers(file_params, monkeypatch):
monkeypatch.setattr(SphinxRenderer, "_random_label", lambda self: "mock-uuid")
document = to_docutils(
Expand All @@ -87,13 +86,13 @@ def test_containers(file_params, monkeypatch):
file_params.assert_expected(document.pformat(), rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "eval_rst.md")
@pytest.mark.param_file(FIXTURE_PATH / "eval_rst.md")
def test_evalrst_elements(file_params):
document = to_docutils(file_params.content, in_sphinx_env=True)
file_params.assert_expected(document.pformat(), rstrip_lines=True)


@with_parameters(FIXTURE_PATH / "definition_lists.md")
@pytest.mark.param_file(FIXTURE_PATH / "definition_lists.md")
def test_definition_lists(file_params):
document = to_docutils(
file_params.content,
Expand Down
5 changes: 2 additions & 3 deletions tests/test_renderers/test_include_directive.py
Expand Up @@ -2,15 +2,14 @@
from pathlib import Path

import pytest
from pytest_param_files import with_parameters

from myst_parser.docutils_renderer import make_document
from myst_parser.main import to_docutils

FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures")


@with_parameters(FIXTURE_PATH / "mock_include.md")
@pytest.mark.param_file(FIXTURE_PATH / "mock_include.md")
def test_render(file_params, tmp_path):
tmp_path.joinpath("other.md").write_text("a\nb\nc")
tmp_path.joinpath("fmatter.md").write_text("---\na: 1\n---\nb")
Expand All @@ -22,7 +21,7 @@ def test_render(file_params, tmp_path):
file_params.assert_expected(output, rstrip=True)


@with_parameters(FIXTURE_PATH / "mock_include_errors.md")
@pytest.mark.param_file(FIXTURE_PATH / "mock_include_errors.md")
def test_errors(file_params, tmp_path):
if file_params.title.startswith("Non-existent path") and os.name == "nt":
pytest.skip("tmp_path not converted correctly on Windows")
Expand Down
4 changes: 2 additions & 2 deletions tests/test_renderers/test_myst_config.py
Expand Up @@ -3,15 +3,15 @@
from io import StringIO
from pathlib import Path

import pytest
from docutils.core import Publisher, publish_doctree
from pytest_param_files import with_parameters

from myst_parser.docutils_ import Parser

FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures")


@with_parameters(FIXTURE_PATH / "myst-config.txt")
@pytest.mark.param_file(FIXTURE_PATH / "myst-config.txt")
def test_cmdline(file_params):
"""The description is parsed as a docutils commandline"""
pub = Publisher(parser=Parser())
Expand Down