Skip to content

Commit

Permalink
Add test case for google#149
Browse files Browse the repository at this point in the history
  • Loading branch information
meshde committed Nov 6, 2018
1 parent 687bf37 commit 88aa2ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fire/fire_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,11 @@ def testTraceErrors(self):
with self.assertRaisesFireExit(2):
fire.Fire(tc.InstanceVars, command=['--arg1=a1', '--arg2=a2', '-', 'jog'])

def testClassWithDefaultMethod(self):
self.assertEqual(
fire.Fire(tc.DefaultMethod, command=['double', '10']), 20
)


if __name__ == '__main__':
testutils.main()
11 changes: 11 additions & 0 deletions fire/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,14 @@ def __call__(self, **kwargs):

def print_msg(self, msg):
print(msg)


class DefaultMethod(object):

def double(self, number):
return 2 * number

def __getattr__(self, name):
def _missing(*args, **kwargs):
return "Undefined Function"
return _missing

0 comments on commit 88aa2ad

Please sign in to comment.