Skip to content

Commit

Permalink
[fix] super subtile bug where on_attribute wasn't set correctly due t…
Browse files Browse the repository at this point in the history
…o root different behavior
  • Loading branch information
Psycojoker committed Jan 31, 2015
1 parent 1190417 commit c4731f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion redbaron.py
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,6 @@ def decrease_indentation(self, number_of_spaces):
def insert_before(self, value, offset=0):
self.parent.insert(self.index_on_parent - offset, value)


def insert_after(self, value, offset=0):
self.parent.insert(self.index_on_parent + 1 + offset, value)

Expand Down Expand Up @@ -2736,6 +2735,12 @@ def __init__(self, source_code):
self.on_attribute = None
self.parent = None

def _convert_input_to_node_object(self, value, parent, on_attribute):
return GenericNodesUtils._convert_input_to_node_object(self, value, self, "root")

def _convert_input_to_node_object_list(self, value, parent, on_attribute):
return GenericNodesUtils._convert_input_to_node_object_list(self, value, self, "root")

def _generate_expected_list(self):
def generate_separator():
separator = self.middle_separator.copy()
Expand Down
8 changes: 8 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from redbaron import RedBaron


def test_mixmatch_with_redbaron_base_node_and_proxy_list_on_parent():
red = RedBaron("foo = 42\nprint 'bar'\n")
red.insert(0, "baz")
assert red[0].on_attribute == "root"
assert red[0].parent is red

0 comments on commit c4731f5

Please sign in to comment.