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.

67 lines
3.1 KiB

  1. import argparse
  2. import pytest
  3. @pytest.fixture
  4. def empty_parser():
  5. return argparse.ArgumentParser(description='description')
  6. @pytest.fixture
  7. def complete_parser():
  8. parser = argparse.ArgumentParser(description='description')
  9. parser.add_argument("req1", help='filename help msg') # positional
  10. parser.add_argument("req2", help="Name of the file where you'll save the output") # positional
  11. parser.add_argument('-r', dest="req3", default=10, type=int, help='sets the time to count down from', required=True)
  12. parser.add_argument('--req4', dest="req4", default=10, type=int, help='sets the time to count down from', required=True)
  13. parser.add_argument("-a", "--aa", action="store_true", help="aaa")
  14. parser.add_argument("-b", "--bb", action="store_true", help="bbb")
  15. parser.add_argument('-c', '--cc', action='count')
  16. parser.add_argument("-d", "--dd", action="store_true", help="ddd")
  17. parser.add_argument('-e', '--ee', choices=['yes', 'no'], help='eee')
  18. parser.add_argument("-f", "--ff", default="0000", help="fff")
  19. parser.add_argument("-g", "--gg", action="store_true", help="ggg")
  20. verbosity = parser.add_mutually_exclusive_group()
  21. verbosity.add_argument('-i', '--ii', action="store_true", help="iii")
  22. verbosity.add_argument('-j', '--jj', action="store_true", help="hhh")
  23. return parser
  24. @pytest.fixture
  25. def subparser():
  26. parser = argparse.ArgumentParser(description='qidev')
  27. parser.add_argument('--verbose', help='be verbose', dest='verbose', action='store_true', default=False)
  28. subs = parser.add_subparsers(help='commands', dest='command')
  29. config_parser = subs.add_parser('config', help='configure defaults for qidev')
  30. config_parser.add_argument('field', help='the field to configure', type=str)
  31. config_parser.add_argument('value', help='set field to value', type=str)
  32. # ########################################################
  33. connect_parser = subs.add_parser('connect', help='connect to a robot (ip/hostname)')
  34. connect_parser.add_argument('hostname', help='hostname or IP address of the robot', type=str)
  35. # ########################################################
  36. install_parser = subs.add_parser('install', help='package and install a project directory on a robot')
  37. install_parser.add_argument('path', help='path to the project directory (containing manifest.xml', type=str)
  38. install_parser.add_argument('--ip', nargs='*', type=str, dest='ip', help='specify hostname(es)/IP address(es)')
  39. return parser
  40. @pytest.fixture
  41. def exclusive_group():
  42. parser = argparse.ArgumentParser(description='description')
  43. verbosity = parser.add_mutually_exclusive_group()
  44. verbosity.add_argument('-i', dest="option1", action="store_true", help="iii")
  45. verbosity.add_argument('-j', dest="option2", action="store_true", help="hhh")
  46. mutually_exclusive_group = [mutex_action
  47. for group_actions in parser._mutually_exclusive_groups
  48. for mutex_action in group_actions._group_actions]
  49. return mutually_exclusive_group
  50. @pytest.fixture
  51. def expected_attrs():
  52. return ('program_icon', 'success_icon', 'running_icon',
  53. 'loading_icon', 'config_icon', 'error_icon')