Skip to content

Commit

Permalink
Merge pull request #49 from nschloe/more-readme
Browse files Browse the repository at this point in the history
add test for hidden cont
  • Loading branch information
nschloe authored May 25, 2021
2 parents 4a32384 + 10db4cd commit 408c8f2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ dolor sit amet
a + 1
```
````
If you'd like to prepend code that you don't want to show, you can just comment it out;
pytest-codeblocks will pick it up anyway:
````markdown
Lorem ipsum
<!--
```python
a = 1
```
-->
dolor sit amet
<!--pytest-codeblocks:cont-->
```python
# this would otherwise fail since `a` is not defined
a + 1
```
````


#### Expected output
You can also define the expected output of a code block:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_cont.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ def test_cont(testdir):
result.assert_outcomes(passed=1)


def test_hidden_cont(testdir):
string = """
Lorem ipsum
<!--
```python
a = 1
```
-->
dolor sit amet
<!--pytest-codeblocks:cont-->
```
a + 1
```
"""
testdir.makefile(".md", string)
result = testdir.runpytest("--codeblocks")
result.assert_outcomes(passed=1)


def test_nocont(testdir):
string = """
<!--pytest-codeblocks:cont-->
Expand Down

0 comments on commit 408c8f2

Please sign in to comment.