помогите на примере написать простенький тест
#!/usr/bin/python3
# -*- coding: UTF-8 -*-
import argparse
class DemoClass():
def __init__(self, Debug):
if Debug:
print("init...")
def some_fn(self, a, b):
return a - b
def create_parser():
parser = argparse.ArgumentParser()
parser.add_argument("--verbose", "-v", action="store_true",
help="set loglevel verbose")
parser.add_argument("--someargs", "-s", nargs="*", action="append", help="Return A - B")
args = parser.parse_args()
debug = False
if args.verbose:
print("Debug...")
debug = True
if args.someargs is not None:
a = int(args.someargs[0][0])
b = int(args.someargs[0][1])
if debug:
print(a, b)
dc = DemoClass(debug)
print("OK, ...", dc.some_fn(a, b))
if __name__ == "__main__":
create_parser()