Skip to content

Commit

Permalink
Merge pull request #98 from nschloe/fix-ws
Browse files Browse the repository at this point in the history
Fix whitespace
  • Loading branch information
nschloe authored Sep 17, 2023
2 parents a8ae092 + f69bdcb commit d0ca7e2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/pytest_codeblocks/__about__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.16.2"
__version__ = "0.17.0"
4 changes: 2 additions & 2 deletions src/pytest_codeblocks/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def runtest(self):
str1 = output

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

if str0 != str1:
raise RuntimeError(
Expand Down
24 changes: 22 additions & 2 deletions tests/test_expected_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,32 @@ def test_expected_output_ignore_whitespace(testdir):
dolor sit amet
<!--pytest-codeblocks:expected-output-ignore-whitespace-->
```
4
-2
4 -2
3
```
"""
testdir.makefile(".md", string)
result = testdir.runpytest("--codeblocks")
result.assert_outcomes(passed=1)


def test_expected_output_ignore_whitespace_fail(testdir):
string = """
Lorem ipsum
```python
print(1 + 3)
print(1 - 3)
print(1 * 3)
```
dolor sit amet
<!--pytest-codeblocks:expected-output-ignore-whitespace-->
```
4 -2
5
```
"""
testdir.makefile(".md", string)
result = testdir.runpytest("--codeblocks")
result.assert_outcomes(failed=1)

0 comments on commit d0ca7e2

Please sign in to comment.