diff --git a/fire/core_test.py b/fire/core_test.py index f48d6e2d..18226e40 100644 --- a/fire/core_test.py +++ b/fire/core_test.py @@ -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']) diff --git a/fire/value_types.py b/fire/value_types.py index 81308973..663afab9 100644 --- a/fire/value_types.py +++ b/fire/value_types.py @@ -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