タグ

ブックマーク / qiita.com/amedama (1)

  • argparseモジュールのversionをテストする - Qiita

    __version__ = '0.0.1' def prepare_parser(): parser = ArgumentParser(description=(__doc__), formatter_class=RawDescriptionHelpFormatter) parser.add_argument('-d', '--debug', action='store_true', help='Show debug log') parser.add_argument('-v', '--version', action='version', version=__version__, help='Show version and exit') return parser このverison部分がちゃんと使えることをテストしたい、とする。 厄介なことに、 parser.parse_args([

    argparseモジュールのversionをテストする - Qiita
    somemo
    somemo 2017/07/22
    “これはargparseのversionアクションの仕様だ。 'version' - This expects a version= keyword argument in the add_argument() call, and prints version information and exits when invoked:”
  • 1