diff --git a/README.md b/README.md index 8f599a1..7b14372 100644 --- a/README.md +++ b/README.md @@ -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 + +dolor sit amet + +```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: diff --git a/tests/test_cont.py b/tests/test_cont.py index 036b39e..3744291 100644 --- a/tests/test_cont.py +++ b/tests/test_cont.py @@ -15,6 +15,25 @@ def test_cont(testdir): result.assert_outcomes(passed=1) +def test_hidden_cont(testdir): + string = """ + Lorem ipsum + + dolor sit amet + + ``` + a + 1 + ``` + """ + testdir.makefile(".md", string) + result = testdir.runpytest("--codeblocks") + result.assert_outcomes(passed=1) + + def test_nocont(testdir): string = """