在第一个单击命令后调用另一个单击命令

时间:2018-09-25 12:36:35

标签: python unit-testing click command-line-interface invoke

我希望看到每个命令被调用后在控制台上打印的结果。

获得第一个结果后,我没有得到第二个结果。

import unittest
import click
from click.testing import CliRunner
import cli.CLI as a

class TestCLI(unittest.TestCase):
    def setUp(self):
        self.runner1 = CliRunner()
        self.runner2 = CliRunner()
        self.args1 = 'arguments 1'
        self.args2 = 'arguments 2'
    def tearDown(self):
        self.runner1 = None
        self.runner2 = None
        self.args1 = None
        self.args2 = None

    def test_1(self):
        result1 = self.runner1.invoke(a.startCLI, self.args1)
        print(result1.output)
        #print console output; is showed
        result2 = self.runner2.invoke(a.startCLI, self.args2)
        print(result2.output)
        #print console output; is blank
if __name__ == '__main__':
    #run test_1
    unittest.main()

0 个答案:

没有答案