Exemplo n.º 1
0
 def testGetArgSpecMethod(self):
   args, varargs, keywords, defaults = inspectutils.GetArgSpec(
       tc.NoDefaults().double)
   self.assertEqual(args, ['count'])
   self.assertEqual(defaults, ())
   self.assertEqual(varargs, None)
   self.assertEqual(keywords, None)
Exemplo n.º 2
0
 def testGetFullArgSpecFromMethod(self):
     spec = inspectutils.GetFullArgSpec(tc.NoDefaults().double)
     self.assertEqual(spec.args, ['count'])
     self.assertEqual(spec.defaults, ())
     self.assertEqual(spec.varargs, None)
     self.assertEqual(spec.varkw, None)
     self.assertEqual(spec.kwonlyargs, [])
     self.assertEqual(spec.kwonlydefaults, {})
     self.assertEqual(spec.annotations, {})
Exemplo n.º 3
0
 def testHelpStringObject(self):
   obj = tc.NoDefaults()
   helpstring = helputils.HelpString(obj)
   self.assertIn('Type:        NoDefaults', helpstring)
   self.assertIn('String form: <fire.test_components.NoDefaults object at ',
                 helpstring)
   # TODO(dbieber): We comment this out since it only works with IPython:
   # self.assertIn('test_components.py', helpstring)
   self.assertIn('Usage:       double\n'
                 '             triple', helpstring)
Exemplo n.º 4
0
 def testHelpStringObject(self):
     obj = tc.NoDefaults()
     helpstring = helputils.HelpString(obj)
     self.assertIn('Type:        NoDefaults', helpstring)
     self.assertIn(
         'String form: <fire.test_components.NoDefaults object at ',
         helpstring)
     self.assertIn('test_components.py', helpstring)
     self.assertIn('Usage:       double\n'
                   '             triple', helpstring)
Exemplo n.º 5
0
    def testUsageOutputMethod(self):
        component = tc.NoDefaults().double
        t = trace.FireTrace(component, name="NoDefaults")
        t.AddAccessedProperty(component, "double", ["double"], None, None)
        usage_output = helptext.UsageText(component, trace=t, verbose=False)
        expected_output = """
    Usage: NoDefaults double COUNT

    For detailed information on this command, run:
      NoDefaults double --help"""
        self.assertEqual(usage_output, textwrap.dedent(expected_output).lstrip("\n"))
Exemplo n.º 6
0
    def testUsageOutputVerbose(self):
        component = tc.NoDefaults()
        t = trace.FireTrace(component, name="NoDefaults")
        usage_output = helptext.UsageText(component, trace=t, verbose=True)
        expected_output = """
    Usage: NoDefaults <command>
      available commands:    double | triple

    For detailed information on this command, run:
      NoDefaults --help"""
        self.assertEqual(usage_output, textwrap.dedent(expected_output).lstrip("\n"))
Exemplo n.º 7
0
 def testHelpTextFunction(self):
     component = tc.NoDefaults().double
     help_screen = helptext.HelpText(component=component,
                                     trace=trace.FireTrace(component,
                                                           name='double'))
     self.assertIn('NAME\n    double', help_screen)
     self.assertIn('SYNOPSIS\n    double COUNT', help_screen)
     self.assertNotIn('DESCRIPTION', help_screen)
     self.assertIn('POSITIONAL ARGUMENTS\n    COUNT', help_screen)
     self.assertIn(
         'NOTES\n    You can also use flags syntax for POSITIONAL ARGUMENTS',
         help_screen)
Exemplo n.º 8
0
    def testUsageOutputMethod(self):
        component = tc.NoDefaults().double
        t = trace.FireTrace(component, name='NoDefaults')
        t.AddAccessedProperty(component, 'double', ['double'], None, None)
        usage_output = helptext.UsageText(component, trace=t, verbose=True)
        expected_output = '''
    Usage: NoDefaults double COUNT

    For detailed information on this command, run:
      NoDefaults double --help'''
        self.assertEqual(usage_output,
                         textwrap.dedent(expected_output).lstrip('\n'))
Exemplo n.º 9
0
 def testHelpTextNoDefaultsObject(self):
     component = tc.NoDefaults()
     help_screen = helptext.HelpText(
         component=component, trace=trace.FireTrace(component, name="NoDefaults")
     )
     self.assertIn("NAME\n    NoDefaults", help_screen)
     self.assertIn("SYNOPSIS\n    NoDefaults COMMAND", help_screen)
     self.assertNotIn("DESCRIPTION", help_screen)
     self.assertIn("COMMANDS\n    COMMAND is one of the following:", help_screen)
     self.assertIn("double", help_screen)
     self.assertIn("triple", help_screen)
     self.assertNotIn("NOTES", help_screen)
Exemplo n.º 10
0
 def testHelpTextNoDefaultsObject(self):
     component = tc.NoDefaults()
     help_screen = helptext.HelpText(component=component,
                                     trace=trace.FireTrace(
                                         component, name='NoDefaults'))
     self.assertIn('NAME\n    NoDefaults', help_screen)
     self.assertIn('SYNOPSIS\n    NoDefaults COMMAND', help_screen)
     self.assertNotIn('DESCRIPTION', help_screen)
     self.assertIn('COMMANDS\n    COMMAND is one of the following:',
                   help_screen)
     self.assertIn('double', help_screen)
     self.assertIn('triple', help_screen)
     self.assertNotIn('NOTES', help_screen)
Exemplo n.º 11
0
    def testUsageOutput(self):
        component = tc.NoDefaults()
        t = trace.FireTrace(component, name='NoDefaults')
        usage_output = helptext.UsageText(component, trace=t, verbose=False)
        expected_output = '''
    Usage: NoDefaults <command>
      available commands:    double | triple

    For detailed information on this command, run:
      NoDefaults --help'''

        self.assertEqual(usage_output,
                         textwrap.dedent(expected_output).lstrip('\n'))
Exemplo n.º 12
0
 def testHelpStringFunction(self):
     obj = tc.NoDefaults()
     helpstring = helputils.HelpString(obj.double)
     if six.PY2:
         self.assertIn('Type:        instancemethod\n', helpstring)
     else:
         self.assertIn('Type:        method\n', helpstring)
     self.assertIn(
         'String form: <bound method NoDefaults.double of '
         '<fire.test_components.NoDefaults object', helpstring)
     self.assertIn('test_components.py', helpstring)
     self.assertIn('Line:        ', helpstring)
     self.assertIn('Usage:       COUNT\n'
                   '             --count COUNT', helpstring)
Exemplo n.º 13
0
  def testUsageOutputVerbose(self):
    component = tc.NoDefaults()
    t = trace.FireTrace(component, name='NoDefaults')
    info = inspectutils.Info(component)
    usage_output = helptext.UsageText(component, info, trace=t, verbose=True)
    expected_output = '''
    Usage: NoDefaults <commands>
    available commands: double | triple

    For detailed information on this command and its flags, run:
    NoDefaults --help
    '''
    self.assertEqual(
        usage_output,
        textwrap.dedent(expected_output).lstrip('\n'))
Exemplo n.º 14
0
    def testUsageOutputVerbose(self):
        component = tc.NoDefaults()
        t = trace.FireTrace(component, name='NoDefaults')
        usage_output = helputils.UsageText(component, trace=t, verbose=True)
        expected_output = '''
    Usage: NoDefaults <groups|commands|values>
    available groups:   __delattr__ | __dict__ | __doc__ | __getattribute__ | __hash__ | __init__ | __repr__ | __setattr__ | __str__ | __weakref__
    available commands: __class__ | __format__ | __new__ | __reduce__ | __reduce_ex__ | __sizeof__ | __subclasshook__ | double | triple
    available values:   __module__

    For detailed information on this command, run:
    NoDefaults --help
    '''
        self.assertEqual(usage_output,
                         textwrap.dedent(expected_output).lstrip('\n'))
Exemplo n.º 15
0
 def testHelpTextNoDefaultsObject(self):
   component = tc.NoDefaults()
   info = inspectutils.Info(component)
   info['docstring_info'] = docstrings.parse(info['docstring'])
   help_screen = helptext.HelpText(
       component=component,
       info=info,
       trace=trace.FireTrace(component, name='NoDefaults'))
   self.assertIn('NAME\n    NoDefaults', help_screen)
   self.assertIn('SYNOPSIS\n    NoDefaults COMMAND', help_screen)
   self.assertNotIn('DESCRIPTION', help_screen)
   self.assertIn('COMMANDS\n    COMMAND is one of the followings:',
                 help_screen)
   self.assertIn('double', help_screen)
   self.assertIn('triple', help_screen)
   self.assertNotIn('NOTES', help_screen)
Exemplo n.º 16
0
 def testMethodCompletions(self):
     completions = completion.Completions(tc.NoDefaults().double)
     self.assertNotIn('--self', completions)
     self.assertIn('--count', completions)
Exemplo n.º 17
0
 def testObjectCompletions(self):
     completions = completion.Completions(tc.NoDefaults())
     self.assertIn('double', completions)
     self.assertIn('triple', completions)