From 49369b910c325200aae49bcc2dd1dd918d60c035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Schl=C3=B6mer?= Date: Sun, 17 Sep 2023 21:14:36 +0200 Subject: [PATCH 1/3] fix for whitespace ignoring --- src/pytest_codeblocks/plugin.py | 4 ++-- tests/test_expected_output.py | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pytest_codeblocks/plugin.py b/src/pytest_codeblocks/plugin.py index 84432f3..d0e931e 100644 --- a/src/pytest_codeblocks/plugin.py +++ b/src/pytest_codeblocks/plugin.py @@ -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( diff --git a/tests/test_expected_output.py b/tests/test_expected_output.py index 0a68bc0..55c0f46 100644 --- a/tests/test_expected_output.py +++ b/tests/test_expected_output.py @@ -47,8 +47,7 @@ def test_expected_output_ignore_whitespace(testdir): dolor sit amet ``` - 4 - -2 + 4 -2 3 ``` @@ -56,3 +55,24 @@ def test_expected_output_ignore_whitespace(testdir): 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 + +``` + 4 -2 + + 5 +``` +""" + testdir.makefile(".md", string) + result = testdir.runpytest("--codeblocks") + result.assert_outcomes(failed=1) From 7580fbb4954b8dc437b057c203ea0d6d09a090d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Schl=C3=B6mer?= Date: Sun, 17 Sep 2023 21:14:54 +0200 Subject: [PATCH 2/3] version bump --- src/pytest_codeblocks/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_codeblocks/__about__.py b/src/pytest_codeblocks/__about__.py index 7f33bc0..755df90 100644 --- a/src/pytest_codeblocks/__about__.py +++ b/src/pytest_codeblocks/__about__.py @@ -1 +1 @@ -__version__ = "0.16.2" +__version__ = "0.16.3" From f69bdcbb0c51eec3c22e695aa3fbab7dd69e2a21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nico=20Schl=C3=B6mer?= Date: Sun, 17 Sep 2023 21:15:05 +0200 Subject: [PATCH 3/3] version bump --- src/pytest_codeblocks/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pytest_codeblocks/__about__.py b/src/pytest_codeblocks/__about__.py index 755df90..fd86b3e 100644 --- a/src/pytest_codeblocks/__about__.py +++ b/src/pytest_codeblocks/__about__.py @@ -1 +1 @@ -__version__ = "0.16.3" +__version__ = "0.17.0"