Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⬆️ UPDATE: docutils v0.19, sphinx v5 (#65)
- Loading branch information
1 parent
fcab0cc
commit 8832b52
Showing
8 changed files
with
60 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,32 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
from pytest_param_files import ParamTestData | ||
|
||
from rst_to_myst import rst_to_myst, to_docutils_ast | ||
from rst_to_myst.utils import read_fixture_file | ||
|
||
FIXTURE_PATH = Path(__file__).parent.joinpath("fixtures") | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"line,title,rst,expected", | ||
read_fixture_file(FIXTURE_PATH / "ast.txt"), | ||
ids=[f"{i[0]}-{i[1]}" for i in read_fixture_file(FIXTURE_PATH / "ast.txt")], | ||
) | ||
def test_ast(line, title, rst, expected): | ||
document, warning_stream = to_docutils_ast(rst) | ||
text = document.pformat() | ||
try: | ||
assert warning_stream.getvalue() == "" | ||
assert text.rstrip() == expected.rstrip() | ||
except AssertionError: | ||
print(text) | ||
raise | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"line,title,rst,expected", | ||
read_fixture_file(FIXTURE_PATH / "render.txt"), | ||
ids=[f"{i[0]}-{i[1]}" for i in read_fixture_file(FIXTURE_PATH / "render.txt")], | ||
) | ||
def test_render(line, title, rst, expected): | ||
output = rst_to_myst(rst) | ||
try: | ||
if "EXPECT_WARNING" not in title: | ||
assert output.warning_stream.getvalue() == "" | ||
else: | ||
assert output.warning_stream.getvalue() != "" | ||
assert output.text.rstrip() == expected.rstrip() | ||
except AssertionError: | ||
print(output.text) | ||
raise | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"line,title,rst,expected", | ||
read_fixture_file(FIXTURE_PATH / "render_extra.txt"), | ||
ids=[ | ||
f"{i[0]}-{i[1]}" for i in read_fixture_file(FIXTURE_PATH / "render_extra.txt") | ||
], | ||
) | ||
def test_render_extra(line, title, rst, expected): | ||
output = rst_to_myst(rst) | ||
try: | ||
@pytest.mark.param_file(FIXTURE_PATH / "ast.txt") | ||
def test_ast(file_params: ParamTestData): | ||
document, warning_stream = to_docutils_ast(file_params.content) | ||
assert warning_stream.getvalue() == "" | ||
file_params.assert_expected(document.pformat(), rstrip=True) | ||
|
||
|
||
@pytest.mark.param_file(FIXTURE_PATH / "render.txt") | ||
def test_render(file_params: ParamTestData): | ||
output = rst_to_myst(file_params.content) | ||
if "EXPECT_WARNING" not in file_params.title: | ||
assert output.warning_stream.getvalue() == "" | ||
assert output.text.rstrip() == expected.rstrip() | ||
except AssertionError: | ||
print(output.text) | ||
raise | ||
else: | ||
assert output.warning_stream.getvalue() != "" | ||
file_params.assert_expected(output.text, rstrip=True) | ||
|
||
|
||
@pytest.mark.param_file(FIXTURE_PATH / "render_extra.txt") | ||
def test_render_extra(file_params: ParamTestData): | ||
output = rst_to_myst(file_params.content) | ||
assert output.warning_stream.getvalue() == "" | ||
file_params.assert_expected(output.text, rstrip=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters