Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions graphtage/pydiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class PyObjAttribute(DataClassNode):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if isinstance(object, StringNode):
object.quoted = False
if isinstance(self.object, StringNode):
self.object.quoted = False
self.attr.quoted = False


Expand Down
13 changes: 12 additions & 1 deletion test/test_pydiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import graphtage
from graphtage.printer import Printer
from graphtage.pydiff import PyDiffFormatter, ast_to_tree, build_tree, print_diff
from graphtage.pydiff import PyDiffFormatter, PyObjAttribute, ast_to_tree, build_tree, print_diff

from .timing import run_with_time_limit

Expand Down Expand Up @@ -35,6 +35,17 @@ def test_python_list_literals_stay_ordered(self):
for node in tree.dfs():
self.assertNotIsInstance(node, graphtage.UnorderedListNode)

def test_attribute_receiver_is_not_quoted(self):
stream = StringIO()
attribute = PyObjAttribute(graphtage.StringNode("package"), graphtage.StringNode("member"))

PyDiffFormatter.DEFAULT_INSTANCE.print(
graphtage.Printer(out_stream=stream, ansi_color=False),
attribute,
)

self.assertEqual("package.member", stream.getvalue())

def test_diff(self):
t1 = [1, 2, {3: "three"}, 4]
t2 = [1, 2, {3: 3}, "four"]
Expand Down