Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whitespace #98

Merged
merged 3 commits into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)