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:
251
251
line [leading_indent :] if line .strip () else "" for line in lines
252
252
)
253
253
254
- return source
254
+ return source . strip ()
255
255
256
256
@property
257
257
def function (self ) -> types .FunctionType :
Original file line number Diff line number Diff line change @@ -85,19 +85,19 @@ def test_get_docstring(self):
85
85
def test_get_function_body (self ):
86
86
assert (
87
87
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()"
89
89
)
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"
92
92
assert (
93
93
CodeInput .get_function_body (self .mock_function_4 )
94
- == "return x # noqa: E702\n "
94
+ == "return x # noqa: E702"
95
95
)
96
96
assert (
97
97
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()"
99
99
)
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"
101
101
with pytest .raises (
102
102
ValueError ,
103
103
match = r"Did not find any def definition. .*" ,
You can’t perform that action at this time.
0 commit comments