Skip to content

Commit

Permalink
Merge pull request #169 from lpsinger/markdown-comments
Browse files Browse the repository at this point in the history
Add comment characters for Markdown
  • Loading branch information
saimn authored Dec 9, 2021
2 parents 713e0c2 + 6819b08 commit a75da2c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

- Fix version check for pytest 7.0.0rc1. [#171]

- Recognize text beginning with `<!--` as a comment for Markdown (`.md`) files.
[#169]

0.11.1 (2021-11-16)
===================

Expand Down
3 changes: 2 additions & 1 deletion pytest_doctestplus/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
comment_characters = {
'.txt': '#',
'.tex': '%',
'.rst': r'\.\.'
'.rst': r'\.\.',
'.md': '<!--'
}


Expand Down
26 changes: 21 additions & 5 deletions tests/test_doctestplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,17 +522,21 @@ def test_show_warnings_rst(testdir):

def test_doctest_glob(testdir):
testdir.makefile(
'.rst',
'.md',
foo_1=">>> 1 + 1\n2",
)
testdir.makefile(
'.rst',
foo_2=">>> 1 + 1\n2",
)
testdir.makefile(
'.txt',
'.rst',
foo_3=">>> 1 + 1\n2",
)
testdir.makefile(
'.txt',
foo_4=">>> 1 + 1\n2",
)
testdir.makefile(
'.rst',
bar_2=">>> 1 + 1\n2",
Expand All @@ -550,30 +554,42 @@ def test_doctest_glob(testdir):
testdir.inline_run(
'--doctest-plus', '--doctest-glob', '*.rst', '--doctest-glob', '*.txt'
).assertoutcome(passed=4)
testdir.inline_run(
'--doctest-plus', '--doctest-glob', '*.rst', '--doctest-glob', '*.txt',
'--doctest-glob', '*.md'
).assertoutcome(passed=5)
testdir.inline_run(
'--doctest-plus', '--doctest-glob', 'foo_*.rst'
).assertoutcome(passed=2)
testdir.inline_run(
'--doctest-plus', '--doctest-glob', 'foo_*.md'
).assertoutcome(passed=1)
testdir.inline_run(
'--doctest-plus', '--doctest-glob', 'foo_*.txt'
).assertoutcome(passed=1)


def test_text_file_comments(testdir):
testdir.makefile(
'.md',
foo_1="<!-- >>> 1 + 1 -->\n3",
)
testdir.makefile(
'.rst',
foo_1=".. >>> 1 + 1\n3",
foo_2=".. >>> 1 + 1\n3",
)
testdir.makefile(
'.tex',
foo_2="% >>> 1 + 1\n3",
foo_3="% >>> 1 + 1\n3",
)
testdir.makefile(
'.txt',
foo_3="# >>> 1 + 1\n3",
foo_4="# >>> 1 + 1\n3",
)

testdir.inline_run(
'--doctest-plus',
'--doctest-glob', '*.md',
'--doctest-glob', '*.rst',
'--doctest-glob', '*.tex',
'--doctest-glob', '*.txt'
Expand Down

0 comments on commit a75da2c

Please sign in to comment.