File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ def get_function_body(function: types.FunctionType) -> str:
251251 line [leading_indent :] if line .strip () else "" for line in lines
252252 )
253253
254- return source
254+ return source . strip ()
255255
256256 @property
257257 def function (self ) -> types .FunctionType :
Original file line number Diff line number Diff line change @@ -85,19 +85,19 @@ def test_get_docstring(self):
8585 def test_get_function_body (self ):
8686 assert (
8787 CodeInput .get_function_body (self .mock_function_1 )
88- == "if x > 0:\n return x + y\n else:\n return y + z()\n "
88+ == "if x > 0:\n return x + y\n else:\n return y + z()"
8989 )
90- assert CodeInput .get_function_body (self .mock_function_2 ) == "return x\n "
91- assert CodeInput .get_function_body (self .mock_function_3 ) == "return x\n "
90+ assert CodeInput .get_function_body (self .mock_function_2 ) == "return x"
91+ assert CodeInput .get_function_body (self .mock_function_3 ) == "return x"
9292 assert (
9393 CodeInput .get_function_body (self .mock_function_4 )
94- == "return x # noqa: E702\n "
94+ == "return x # noqa: E702"
9595 )
9696 assert (
9797 CodeInput .get_function_body (self .mock_function_5 )
98- == "def x():\n return 5\n return x()\n "
98+ == "def x():\n return 5\n return x()"
9999 )
100- assert CodeInput .get_function_body (self .mock_function_6 ) == "return x\n "
100+ assert CodeInput .get_function_body (self .mock_function_6 ) == "return x"
101101 with pytest .raises (
102102 ValueError ,
103103 match = r"Did not find any def definition. .*" ,
You can’t perform that action at this time.
0 commit comments