Ejemplo n.º 1
0
def test_calculator_with_division(capsys):
    with patch('sys.argv', ['', 'd', '2', '4']):
        app = asynccli.App(Calculator)
        app.run()

    out, _ = capsys.readouterr()
    assert out == "0.5\n"
Ejemplo n.º 2
0
def test_calculator_with_multiplication(capsys):
    with patch('sys.argv', ['', 'm', '2', '4']):
        app = asynccli.App(Calculator)
        app.run()

    out, _ = capsys.readouterr()
    assert out == "8\n"
Ejemplo n.º 3
0
def test_division_calculator(capsys):
    # sys.argv = ['1', '2']

    with patch('sys.argv', ['', '1', '2']):
        app = asynccli.App(Calculator)
        app.run()

    out, _ = capsys.readouterr()
    assert out == "0.5\n"
Ejemplo n.º 4
0
import asynccli


class MyCLI(asynccli.CLI):
    async def call(self):
        print("Hello, world.")


if __name__ == '__main__':
    app = asynccli.App(MyCLI)
    app.run()
Ejemplo n.º 5
0
import asynccli


async def mycli():
    print("Hello, world.")


class MultiplicationCalculator(asynccli.CLI):
    first_num = asynccli.Integer(help_text='This is some help text.')
    second_num = asynccli.Integer()

    async def call(self):
        print(self.first_num * self.second_num)


class Calculator(asynccli.TieredCLI):
    m = MultiplicationCalculator


if __name__ == '__main__':
    app = asynccli.App(Calculator, mycli)
    app.run()
Ejemplo n.º 6
0
import asynccli


async def mycli():
    print("Hello, world.")


if __name__ == '__main__':
    app = asynccli.App(mycli)
    app.run()
Ejemplo n.º 7
0
def test_hello_world_class(capsys):
    app = asynccli.App(MyCLI)
    app.run()

    out, _ = capsys.readouterr()
    assert out == "Hello, world.\n"
Ejemplo n.º 8
0
def test_hello_world_basic(capsys):
    app = asynccli.App(mycli)
    app.run()

    out, _ = capsys.readouterr()
    assert out == "Hello, world.\n"
Ejemplo n.º 9
0
def test_setup_teardown(capsys):
    app = asynccli.App(MyCLI)
    app.run()

    out, _ = capsys.readouterr()
    assert out == "setup\nHello, world.\nteardown\n"
Ejemplo n.º 10
0
import asynccli


class DivisionCalculator(asynccli.CLI):
    first_num = asynccli.Integer(help_text='This is some help text.')
    second_num = asynccli.Integer()

    async def call(self):
        print(self.first_num / self.second_num)


if __name__ == '__main__':
    app = asynccli.App(DivisionCalculator)
    app.run()