You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.2 KiB

  1. import unittest
  2. from argparse import ArgumentParser
  3. from python_bindings.config_generator import create_from_parser
  4. class TextConfigGenerator(unittest.TestCase):
  5. def test_program_description(self):
  6. """
  7. Should use `program_description` if supplied, otherwise
  8. fallback to the description on the `parser`
  9. """
  10. parser = ArgumentParser(description="Parser Description")
  11. # when supplied explicitly, we assign it as the description
  12. buildspec = create_from_parser(parser, "", program_description='Custom Description')
  13. self.assertEqual(buildspec['program_description'], 'Custom Description')
  14. # when no explicit program_definition supplied, we fallback to the parser's description
  15. buildspec = create_from_parser(parser, "")
  16. self.assertEqual(buildspec['program_description'], 'Parser Description')
  17. # if no description is provided anywhere, we just set it to be an empty string.
  18. blank_parser = ArgumentParser()
  19. buildspec = create_from_parser(blank_parser, "")
  20. self.assertEqual(buildspec['program_description'], '')
  21. if __name__ == '__main__':
  22. unittest.main()