Skip to content

Commit

Permalink
[fix] allow to modify _formatting attributes on CodeBlockNodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Psycojoker committed Mar 11, 2015
1 parent 5f70d56 commit 6efa12a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions redbaron.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,9 @@ def _string_to_node_list(self, string, parent, on_attribute):
if on_attribute == "value":
return self.parse_code_block(string, parent=parent, on_attribute=on_attribute)

elif on_attribute.endswith("_formatting"):
return super(CodeBlockNode, self)._string_to_node_list(string, parent, on_attribute)

else:
raise Exception("Unhandled case")

Expand Down
6 changes: 6 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ def test_mixmatch_with_redbaron_base_node_and_proxy_list_on_parent():
red.insert(0, "baz")
assert red[0].on_attribute == "root"
assert red[0].parent is red


def test_can_modify_formatting_attributes_on_codeblocknodes():
red = RedBaron("class Foo:\n def bar(): pass")
red.class_.first_formatting = " " # shouldn't raise
red.def_.second_formatting = " " # same

0 comments on commit 6efa12a

Please sign in to comment.