谁能告诉我如何测试用Docopt(Python)编写的cli应用程序?GitHub上有人发了这个,
import unittest
from docopt import docopt
import your.entry.point.of.sum as sum
# you can import the doc string from the sum module
doc = sum.__doc__
# suppose now the doc is:
# Sum two numbers.
# Usage: summation.py <x> <y>
# then write your test cases
class TestCLIParser(unittest.TestCase):
def test_sum(self):
args = docopt(doc, ["1", "3"])
self.assertEqual(args["<x>"], "1")
self.assertEqual(args["<y>"], "3")
def and_so_on(self):
...
我有这个但是有人可以告诉我如何测试程序的输出吗?此示例仅测试参数