From 1f366f97602a1806f623ae73f07888abd61162ca Mon Sep 17 00:00:00 2001 From: Saurabh Patel Date: Wed, 19 Apr 2017 09:56:02 -0700 Subject: [PATCH] Bug Fix : name was not setting if command is set (#65) * default name was not used when a command was provided --- fire/core.py | 3 ++- fire/fire_test.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/fire/core.py b/fire/core.py index 39ba442a..3a0712e9 100644 --- a/fire/core.py +++ b/fire/core.py @@ -101,12 +101,13 @@ def Fire(component=None, command=None, name=None): # Get args as a list. if command is None: # Use the command line args by default if no command is specified. - name = name or os.path.basename(sys.argv[0]) args = sys.argv[1:] else: # Otherwise use the specified command. args = shlex.split(command) + name = name or os.path.basename(sys.argv[0]) + # Determine the calling context. caller = inspect.stack()[1] caller_frame = caller[0] diff --git a/fire/fire_test.py b/fire/fire_test.py index 648c676b..38652a31 100644 --- a/fire/fire_test.py +++ b/fire/fire_test.py @@ -324,8 +324,9 @@ def testHelpFlagAndTraceFlag(self): fire.Fire(tc.BoolConverter, '-- -h --trace') def testTabCompletionNoName(self): - with self.assertRaises(ValueError): - fire.Fire(tc.NoDefaults, '-- --completion') + completion_script = fire.Fire(tc.NoDefaults, '-- --completion') + self.assertIn('double', completion_script) + self.assertIn('triple', completion_script) def testTabCompletion(self): completion_script = fire.Fire(tc.NoDefaults, '-- --completion', name='c')