Skip to content

Commit d0ca7e2

Browse files
authored
Merge pull request #98 from nschloe/fix-ws
Fix whitespace
2 parents a8ae092 + f69bdcb commit d0ca7e2

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/pytest_codeblocks/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.16.2"
1+
__version__ = "0.17.0"

src/pytest_codeblocks/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def runtest(self):
108108
str1 = output
109109

110110
if self.obj.expected_output_ignore_whitespace:
111-
str0 = re.sub(r"^\s+", "", str0, flags=re.MULTILINE)
112-
str1 = re.sub(r"^\s+", "", str1, flags=re.MULTILINE)
111+
str0 = re.sub(r"\s+", "", str0)
112+
str1 = re.sub(r"\s+", "", str1)
113113

114114
if str0 != str1:
115115
raise RuntimeError(

tests/test_expected_output.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,32 @@ def test_expected_output_ignore_whitespace(testdir):
4747
dolor sit amet
4848
<!--pytest-codeblocks:expected-output-ignore-whitespace-->
4949
```
50-
4
51-
-2
50+
4 -2
5251
5352
3
5453
```
5554
"""
5655
testdir.makefile(".md", string)
5756
result = testdir.runpytest("--codeblocks")
5857
result.assert_outcomes(passed=1)
58+
59+
60+
def test_expected_output_ignore_whitespace_fail(testdir):
61+
string = """
62+
Lorem ipsum
63+
```python
64+
print(1 + 3)
65+
print(1 - 3)
66+
print(1 * 3)
67+
```
68+
dolor sit amet
69+
<!--pytest-codeblocks:expected-output-ignore-whitespace-->
70+
```
71+
4 -2
72+
73+
5
74+
```
75+
"""
76+
testdir.makefile(".md", string)
77+
result = testdir.runpytest("--codeblocks")
78+
result.assert_outcomes(failed=1)

0 commit comments

Comments
 (0)