From 3e981f759d14280fe1836630ef3fb74ba259c481 Mon Sep 17 00:00:00 2001 From: HomieOmie Date: Sat, 6 May 2023 00:43:40 -0400 Subject: [PATCH 01/13] Permanently added pytest-cov in pyproject.toml file to generate coverage reports --- pyproject.toml | 4 ++-- testing/examples/my_test.py | 6 ++++++ tox.ini | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 testing/examples/my_test.py diff --git a/pyproject.toml b/pyproject.toml index a4139a5c0..22239743d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,13 @@ build-backend = "setuptools.build_meta" write_to = "src/_pytest/_version.py" [tool.pytest.ini_options] -minversion = "2.0" +minversion = "0.1.dev14953+gfd6a450" addopts = "-rfEX -p pytester --strict-markers" python_files = ["test_*.py", "*_test.py", "testing/python/*.py"] python_classes = ["Test", "Acceptance"] python_functions = ["test"] # NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". -testpaths = ["testing"] +testpaths = ["testing/examples/my_test.py"] norecursedirs = ["testing/example_scripts"] xfail_strict = true filterwarnings = [ diff --git a/testing/examples/my_test.py b/testing/examples/my_test.py new file mode 100644 index 000000000..4cd697be7 --- /dev/null +++ b/testing/examples/my_test.py @@ -0,0 +1,6 @@ +def test_(): + m = [ + "This is some dummy test which shows the strange way in which Pycharm" + " displays the full diff." + ] + assert m == [] diff --git a/tox.ini b/tox.ini index 88ae16dea..05711b02f 100644 --- a/tox.ini +++ b/tox.ini @@ -65,6 +65,7 @@ deps = xdist: pytest-xdist>=2.1.0 xdist: -e . {env:_PYTEST_TOX_EXTRA_DEP:} + pytest-cov [testenv:linting] skip_install = True From f526975234ae9afbb48c71da14b88b8f219b7e94 Mon Sep 17 00:00:00 2001 From: HomieOmie Date: Sat, 6 May 2023 03:21:57 -0400 Subject: [PATCH 02/13] Added some final touched to test file and code for terminal output. More may be done eventually --- src/_pytest/_code/code.py | 19 ++++++++++++++++++- testing/examples/my_test.py | 16 ++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index 5bc78f478..aa96ee43f 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1165,11 +1165,28 @@ class ReprEntry(TerminalRepr): else: indents.append(line[:indent_size]) source_lines.append(line[indent_size:]) - + # print(source_lines) tw._write_source(source_lines, indents) # failure lines are always completely red and bold + for i in range(len(failure_lines)): + line_list = failure_lines[i].split() + # This will swap the extra comma in the multiline string with the position of the starting bracket + if len(line_list) == 3 and line_list[2] == "," and line_list[1] == "-": + prev_arg = failure_lines[i - 1] + failure_lines[i - 1] = failure_lines[i] + failure_lines[i] = prev_arg + for line in failure_lines: + line_list = line.split() + # multiline case seems to be an issue with just an added ',' + if len(line_list) == 3 and line_list[2] == "," and line_list[1] == "-": + line = line.replace(",", "[]") + # This is to remove the extra whitespace between '-' and '[]' + line_list = list(line) + extra_wp_i = line_list.index("-") + 1 + line_list.pop(extra_wp_i) + line = "".join(line_list) tw.line(line, bold=True, red=True) def toterminal(self, tw: TerminalWriter) -> None: diff --git a/testing/examples/my_test.py b/testing/examples/my_test.py index 4cd697be7..c4763bc70 100644 --- a/testing/examples/my_test.py +++ b/testing/examples/my_test.py @@ -4,3 +4,19 @@ def test_(): " displays the full diff." ] assert m == [] + + +def test2_(): + m = [ + "This is another check" + " This line and the line above should be fine" + " Same with this line" + " But we should not see the '- ,' appear" + " But rather we should see a '- []' appear" + ] + assert m == [] + + +def test3_(): + m = ["This is some dummy test which shows the strange way in which Pycharm"] + assert m == [] From 5f86e6f506d6503bfa6f44e55b25b7eb0ab73ece Mon Sep 17 00:00:00 2001 From: HomieOmie <93492271+HomieOmie@users.noreply.github.com> Date: Sat, 6 May 2023 17:56:42 -0400 Subject: [PATCH 03/13] Update pyproject.toml Forgot to change back pyproject.toml to default --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 22239743d..a4139a5c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,13 @@ build-backend = "setuptools.build_meta" write_to = "src/_pytest/_version.py" [tool.pytest.ini_options] -minversion = "0.1.dev14953+gfd6a450" +minversion = "2.0" addopts = "-rfEX -p pytester --strict-markers" python_files = ["test_*.py", "*_test.py", "testing/python/*.py"] python_classes = ["Test", "Acceptance"] python_functions = ["test"] # NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". -testpaths = ["testing/examples/my_test.py"] +testpaths = ["testing"] norecursedirs = ["testing/example_scripts"] xfail_strict = true filterwarnings = [ From ac3cb751a3f4af5982306b3eb5875b107ca91c44 Mon Sep 17 00:00:00 2001 From: HomieOmie Date: Sat, 6 May 2023 18:27:52 -0400 Subject: [PATCH 04/13] Resolved merge issues --- src/_pytest/_code/code.py | 14 ++++++++++++++ testing/examples/my_test.py | 14 +++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index aa96ee43f..e2a30dd39 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1158,6 +1158,10 @@ class ReprEntry(TerminalRepr): if is_failure_line: # from this point on all lines are considered part of the failure failure_lines.extend(self.lines[index:]) + + for line in self.lines[index:]: + print(line) + break else: if self.style == "value": @@ -1180,6 +1184,8 @@ class ReprEntry(TerminalRepr): for line in failure_lines: line_list = line.split() # multiline case seems to be an issue with just an added ',' + # print(line_list) + # These are edge cases for empty lists if len(line_list) == 3 and line_list[2] == "," and line_list[1] == "-": line = line.replace(",", "[]") # This is to remove the extra whitespace between '-' and '[]' @@ -1187,6 +1193,14 @@ class ReprEntry(TerminalRepr): extra_wp_i = line_list.index("-") + 1 line_list.pop(extra_wp_i) line = "".join(line_list) + elif len(line_list) == 3 and line_list[2] == "," and line_list[1] == "+": + line = line.replace(",", "[]") + # This is to remove the extra whitespace between '+' and '[]' + line_list = list(line) + extra_wp_i = line_list.index("+") + 1 + line_list.pop(extra_wp_i) + line = "".join(line_list) + # print(line) tw.line(line, bold=True, red=True) def toterminal(self, tw: TerminalWriter) -> None: diff --git a/testing/examples/my_test.py b/testing/examples/my_test.py index c4763bc70..3c6edde0e 100644 --- a/testing/examples/my_test.py +++ b/testing/examples/my_test.py @@ -10,13 +10,13 @@ def test2_(): m = [ "This is another check" " This line and the line above should be fine" - " Same with this line" - " But we should not see the '- ,' appear" - " But rather we should see a '- []' appear" + "Same with this line" + "But we should not see the '- ,' appear" + "But rather we should see a '- []' appear" ] - assert m == [] + assert [] == m -def test3_(): - m = ["This is some dummy test which shows the strange way in which Pycharm"] - assert m == [] +# def test3_(): +# m = ["This is some dummy test which shows the strange way in which Pycharm"] +# assert m == [] From d783aca2218e22f323e40e76ae4ebfa6af5a619d Mon Sep 17 00:00:00 2001 From: HomieOmie Date: Sat, 6 May 2023 18:59:12 -0400 Subject: [PATCH 05/13] Changed styling of test file --- pyproject.toml | 4 ++-- testing/examples/my_test.py | 22 ---------------------- testing/examples/test_issue10863.py | 6 ++++++ 3 files changed, 8 insertions(+), 24 deletions(-) delete mode 100644 testing/examples/my_test.py create mode 100644 testing/examples/test_issue10863.py diff --git a/pyproject.toml b/pyproject.toml index a4139a5c0..d63cceafd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,13 +10,13 @@ build-backend = "setuptools.build_meta" write_to = "src/_pytest/_version.py" [tool.pytest.ini_options] -minversion = "2.0" +minversion = "0.1.dev14957+gac3cb75.d20230506" addopts = "-rfEX -p pytester --strict-markers" python_files = ["test_*.py", "*_test.py", "testing/python/*.py"] python_classes = ["Test", "Acceptance"] python_functions = ["test"] # NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". -testpaths = ["testing"] +testpaths = ["testing/examples/my_test.py"] norecursedirs = ["testing/example_scripts"] xfail_strict = true filterwarnings = [ diff --git a/testing/examples/my_test.py b/testing/examples/my_test.py deleted file mode 100644 index 3c6edde0e..000000000 --- a/testing/examples/my_test.py +++ /dev/null @@ -1,22 +0,0 @@ -def test_(): - m = [ - "This is some dummy test which shows the strange way in which Pycharm" - " displays the full diff." - ] - assert m == [] - - -def test2_(): - m = [ - "This is another check" - " This line and the line above should be fine" - "Same with this line" - "But we should not see the '- ,' appear" - "But rather we should see a '- []' appear" - ] - assert [] == m - - -# def test3_(): -# m = ["This is some dummy test which shows the strange way in which Pycharm"] -# assert m == [] diff --git a/testing/examples/test_issue10863.py b/testing/examples/test_issue10863.py new file mode 100644 index 000000000..4cd697be7 --- /dev/null +++ b/testing/examples/test_issue10863.py @@ -0,0 +1,6 @@ +def test_(): + m = [ + "This is some dummy test which shows the strange way in which Pycharm" + " displays the full diff." + ] + assert m == [] From 37160073915eb0e836b1052993fcbdc04b2555b6 Mon Sep 17 00:00:00 2001 From: HomieOmie <93492271+HomieOmie@users.noreply.github.com> Date: Sat, 6 May 2023 19:41:36 -0400 Subject: [PATCH 06/13] Update and rename my_test.py to test_issue10863.py --- testing/examples/my_test.py | 22 ---------------------- testing/examples/test_issue10863.py | 6 ++++++ 2 files changed, 6 insertions(+), 22 deletions(-) delete mode 100644 testing/examples/my_test.py create mode 100644 testing/examples/test_issue10863.py diff --git a/testing/examples/my_test.py b/testing/examples/my_test.py deleted file mode 100644 index 3c6edde0e..000000000 --- a/testing/examples/my_test.py +++ /dev/null @@ -1,22 +0,0 @@ -def test_(): - m = [ - "This is some dummy test which shows the strange way in which Pycharm" - " displays the full diff." - ] - assert m == [] - - -def test2_(): - m = [ - "This is another check" - " This line and the line above should be fine" - "Same with this line" - "But we should not see the '- ,' appear" - "But rather we should see a '- []' appear" - ] - assert [] == m - - -# def test3_(): -# m = ["This is some dummy test which shows the strange way in which Pycharm"] -# assert m == [] diff --git a/testing/examples/test_issue10863.py b/testing/examples/test_issue10863.py new file mode 100644 index 000000000..4cd697be7 --- /dev/null +++ b/testing/examples/test_issue10863.py @@ -0,0 +1,6 @@ +def test_(): + m = [ + "This is some dummy test which shows the strange way in which Pycharm" + " displays the full diff." + ] + assert m == [] From 097f3bc9805f2bf45ba4aaa8108ef8839b750b1c Mon Sep 17 00:00:00 2001 From: HomieOmie Date: Sat, 6 May 2023 19:08:23 -0400 Subject: [PATCH 07/13] Got rid of unnecessary comments --- pyproject.toml | 4 ++-- src/_pytest/_code/code.py | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d63cceafd..d78f38e67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,14 +10,14 @@ build-backend = "setuptools.build_meta" write_to = "src/_pytest/_version.py" [tool.pytest.ini_options] -minversion = "0.1.dev14957+gac3cb75.d20230506" +minversion = "2.0" addopts = "-rfEX -p pytester --strict-markers" python_files = ["test_*.py", "*_test.py", "testing/python/*.py"] python_classes = ["Test", "Acceptance"] python_functions = ["test"] # NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". testpaths = ["testing/examples/my_test.py"] -norecursedirs = ["testing/example_scripts"] +norecursedirs = ["testing"] xfail_strict = true filterwarnings = [ "error", diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index e2a30dd39..b5150272a 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1169,7 +1169,6 @@ class ReprEntry(TerminalRepr): else: indents.append(line[:indent_size]) source_lines.append(line[indent_size:]) - # print(source_lines) tw._write_source(source_lines, indents) # failure lines are always completely red and bold @@ -1184,7 +1183,6 @@ class ReprEntry(TerminalRepr): for line in failure_lines: line_list = line.split() # multiline case seems to be an issue with just an added ',' - # print(line_list) # These are edge cases for empty lists if len(line_list) == 3 and line_list[2] == "," and line_list[1] == "-": line = line.replace(",", "[]") @@ -1200,7 +1198,6 @@ class ReprEntry(TerminalRepr): extra_wp_i = line_list.index("+") + 1 line_list.pop(extra_wp_i) line = "".join(line_list) - # print(line) tw.line(line, bold=True, red=True) def toterminal(self, tw: TerminalWriter) -> None: From 77a9eae5a1e3a49250b68cac28238be76cdc2e2b Mon Sep 17 00:00:00 2001 From: HomieOmie Date: Sat, 6 May 2023 19:13:49 -0400 Subject: [PATCH 08/13] Committing changes --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d78f38e67..a4139a5c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,8 +16,8 @@ python_files = ["test_*.py", "*_test.py", "testing/python/*.py"] python_classes = ["Test", "Acceptance"] python_functions = ["test"] # NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". -testpaths = ["testing/examples/my_test.py"] -norecursedirs = ["testing"] +testpaths = ["testing"] +norecursedirs = ["testing/example_scripts"] xfail_strict = true filterwarnings = [ "error", From e262c12858236a4858d9e063d3a9532ecd633690 Mon Sep 17 00:00:00 2001 From: HomieOmie <93492271+HomieOmie@users.noreply.github.com> Date: Sat, 6 May 2023 19:56:53 -0400 Subject: [PATCH 09/13] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d78f38e67..cef7355fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ python_files = ["test_*.py", "*_test.py", "testing/python/*.py"] python_classes = ["Test", "Acceptance"] python_functions = ["test"] # NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". -testpaths = ["testing/examples/my_test.py"] +testpaths = ["testing"] norecursedirs = ["testing"] xfail_strict = true filterwarnings = [ From 865a7646c072a9c9e2884f53000bb3719ef55c85 Mon Sep 17 00:00:00 2001 From: HomieOmie <93492271+HomieOmie@users.noreply.github.com> Date: Sat, 6 May 2023 20:28:19 -0400 Subject: [PATCH 10/13] Update tox.ini --- tox.ini | 1 - 1 file changed, 1 deletion(-) diff --git a/tox.ini b/tox.ini index 05711b02f..88ae16dea 100644 --- a/tox.ini +++ b/tox.ini @@ -65,7 +65,6 @@ deps = xdist: pytest-xdist>=2.1.0 xdist: -e . {env:_PYTEST_TOX_EXTRA_DEP:} - pytest-cov [testenv:linting] skip_install = True From 5f338bf0e3c1d89099a26a14faf877d36cd41ed3 Mon Sep 17 00:00:00 2001 From: HomieOmie <93492271+HomieOmie@users.noreply.github.com> Date: Sat, 6 May 2023 20:30:06 -0400 Subject: [PATCH 11/13] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cef7355fa..a4139a5c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ python_classes = ["Test", "Acceptance"] python_functions = ["test"] # NOTE: "doc" is not included here, but gets tested explicitly via "doctesting". testpaths = ["testing"] -norecursedirs = ["testing"] +norecursedirs = ["testing/example_scripts"] xfail_strict = true filterwarnings = [ "error", From d0d96c71d6fa16032006f7a7a3b941c2f9eef61e Mon Sep 17 00:00:00 2001 From: HomieOmie <93492271+HomieOmie@users.noreply.github.com> Date: Sat, 6 May 2023 20:34:02 -0400 Subject: [PATCH 12/13] Delete test_issue10863.py Causing issues with main test suite --- testing/examples/test_issue10863.py | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 testing/examples/test_issue10863.py diff --git a/testing/examples/test_issue10863.py b/testing/examples/test_issue10863.py deleted file mode 100644 index 4cd697be7..000000000 --- a/testing/examples/test_issue10863.py +++ /dev/null @@ -1,6 +0,0 @@ -def test_(): - m = [ - "This is some dummy test which shows the strange way in which Pycharm" - " displays the full diff." - ] - assert m == [] From 6fefbb82e8612571ff61e98f7d9d90143f88b51a Mon Sep 17 00:00:00 2001 From: HomieOmie <93492271+HomieOmie@users.noreply.github.com> Date: Sat, 6 May 2023 20:35:13 -0400 Subject: [PATCH 13/13] Update code.py to stop printing wrong outputs to terminal --- src/_pytest/_code/code.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/_pytest/_code/code.py b/src/_pytest/_code/code.py index b5150272a..bafc66868 100644 --- a/src/_pytest/_code/code.py +++ b/src/_pytest/_code/code.py @@ -1158,10 +1158,6 @@ class ReprEntry(TerminalRepr): if is_failure_line: # from this point on all lines are considered part of the failure failure_lines.extend(self.lines[index:]) - - for line in self.lines[index:]: - print(line) - break else: if self.style == "value":