diff --git a/src/_pytest/_code/source.py b/src/_pytest/_code/source.py index 6c9aaa7e6..019da5765 100644 --- a/src/_pytest/_code/source.py +++ b/src/_pytest/_code/source.py @@ -89,19 +89,6 @@ class Source: source.lines[:] = self.lines[start:end] return source - def putaround( - self, before: str = "", after: str = "", indent: str = " " * 4 - ) -> "Source": - """ return a copy of the source object with - 'before' and 'after' wrapped around it. - """ - beforesource = Source(before) - aftersource = Source(after) - newsource = Source() - lines = [(indent + line) for line in self.lines] - newsource.lines = beforesource.lines + lines + aftersource.lines - return newsource - def indent(self, indent: str = " " * 4) -> "Source": """ return a copy of the source object with all lines indented by the given indent-string. diff --git a/testing/code/test_source.py b/testing/code/test_source.py index 0bf8c0b17..97a00964b 100644 --- a/testing/code/test_source.py +++ b/testing/code/test_source.py @@ -69,39 +69,6 @@ def test_source_from_inner_function() -> None: assert str(source).startswith("def f():") -def test_source_putaround_simple() -> None: - source = Source("raise ValueError") - source = source.putaround( - "try:", - """\ - except ValueError: - x = 42 - else: - x = 23""", - ) - assert ( - str(source) - == """\ -try: - raise ValueError -except ValueError: - x = 42 -else: - x = 23""" - ) - - -def test_source_putaround() -> None: - source = Source() - source = source.putaround( - """ - if 1: - x=1 - """ - ) - assert str(source).strip() == "if 1:\n x=1" - - def test_source_strips() -> None: source = Source("") assert source == Source()