Skip to content
Open
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
12 changes: 12 additions & 0 deletions fire/core_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ def testPrintOrderedDict(self):
with self.assertOutputMatches(stdout='{}'):
core.Fire(tc.OrderedDictionary, command=['empty'])

def testPrintDictWithSetValue(self):
def make_returns_set_value(value):
def returns_set_value():
return {'items': value}
return returns_set_value

for value, expected in (({1}, r'\{1\}'),
(frozenset({1}), r'frozenset\(\{1\}\)')):
with self.assertOutputMatches(stdout=rf'items:\s+{expected}\s+',
stderr=None):
core.Fire(make_returns_set_value(value), command=[])

def testPrintNamedTupleField(self):
with self.assertOutputMatches(stdout='11', stderr=None):
core.Fire(tc.NamedTuple, command=['point', 'x'])
Expand Down
3 changes: 2 additions & 1 deletion fire/value_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def IsSimpleGroup(component):
"""
assert isinstance(component, dict)
for unused_key, value in component.items():
if not IsValue(value) and not isinstance(value, (list, dict)):
if not IsValue(value) and not isinstance(
value, (list, set, frozenset, dict)):
return False
return True

Expand Down