Skip to content

Commit

Permalink
test(extract-method) recreating bug: Unable do extract method with tr…
Browse files Browse the repository at this point in the history
…y and subscriptable

refs python-rope#459
  • Loading branch information
dryobates committed Mar 15, 2022
1 parent 79586d1 commit cddc9e2
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ropetest/refactor/extracttest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,30 @@ def g():
""")
self.assertEqual(expected, refactored)

def test_extract_method_and_augmentedj_assignment_in_try_block(self):
code = dedent("""\
def f():
any_subscriptable = [0]
try:
any_subscriptable[0] += 1
except Exception:
pass
""")
start, end = self._convert_line_range_to_offset(code, 2, 6)
refactored = self.do_extract_method(code, start, end, "g")
expected = dedent("""\
def f():
g()
def g():
any_subscriptable = [0]
try:
any_subscriptable[0] += 1
except Exception:
pass
""")
self.assertEqual(expected, refactored)

def test_extract_and_not_passing_global_functions(self):
code = dedent("""\
def next(p):
Expand Down

0 comments on commit cddc9e2

Please sign in to comment.