diff --git a/fire/core.py b/fire/core.py index 6fd1bf7a..c554ca3d 100644 --- a/fire/core.py +++ b/fire/core.py @@ -164,7 +164,8 @@ def Fire(component=None, command=None, name=None, serialize=None): raise FireExit(0, component_trace) # The command succeeded normally; print the result. - _PrintResult(component_trace, verbose=component_trace.verbose, serialize=serialize) + _PrintResult( + component_trace, verbose=component_trace.verbose, serialize=serialize) result = component_trace.GetResult() return result @@ -247,11 +248,11 @@ def _PrintResult(component_trace, verbose=False, serialize=None): # and move serialization to its own module. result = component_trace.GetResult() - # Allow users to modify the return value of the component and provide + # Allow users to modify the return value of the component and provide # custom formatting. if serialize: if not callable(serialize): - raise FireError("serialize argument {} must be empty or callable.".format(serialize)) + raise FireError('The argument `serialize` must be empty or callable:', serialize) result = serialize(result) if value_types.HasCustomStr(result): diff --git a/fire/core_test.py b/fire/core_test.py index a0576ee9..e9987da6 100644 --- a/fire/core_test.py +++ b/fire/core_test.py @@ -205,15 +205,16 @@ def serialize(x): return x ident = lambda x: x - + with self.assertOutputMatches(stdout='a, b', stderr=None): - result = core.Fire(ident, command=['[a,b]'], serialize=serialize) + _ = core.Fire(ident, command=['[a,b]'], serialize=serialize) with self.assertOutputMatches(stdout='a=5, b=6', stderr=None): - result = core.Fire(ident, command=['{a:5,b:6}'], serialize=serialize) + _ = core.Fire(ident, command=['{a:5,b:6}'], serialize=serialize) with self.assertOutputMatches(stdout='asdf', stderr=None): - result = core.Fire(ident, command=['asdf'], serialize=serialize) - with self.assertOutputMatches(stdout="SURPRISE!!\nI'm a list!\n", stderr=None): - result = core.Fire(ident, command=['special'], serialize=serialize) + _ = core.Fire(ident, command=['asdf'], serialize=serialize) + with self.assertOutputMatches( + stdout="SURPRISE!!\nI'm a list!\n", stderr=None): + _ = core.Fire(ident, command=['special'], serialize=serialize) with self.assertRaises(core.FireError): core.Fire(ident, command=['asdf'], serialize=55)