async def test_interactive_command(capsys, monkeypatch): async def mocked_prepare_execute(req, arg): print(req) inputs = ['req1', 'req2', '\x03'] def mocked_input(prompt): i = inputs.pop(0) if i == '\x03': raise SystemExit() return i monkeypatch.setattr('builtins.input', mocked_input) monkeypatch.setattr(commands, 'prepare_and_execute_request', mocked_prepare_execute) with pytest.raises(SystemExit): await interactive_command({}) captured = capsys.readouterr() assert escape_ansi( captured.out) == '''Dbgr interactive mode; press ^C to exit.
def test_format_without_type(): r = Result('string value') assert escape_ansi(r) == 'string value'
def test_format_none(): r = Result(None, Type(), False) assert escape_ansi(r) == 'None'
async def test_list_command_module_not_found(monkeypatch, capsys): requests = {'module': {'req': mock_request(name='req', module='module')}} monkeypatch.setattr(commands, 'get_requests', lambda: requests) await list_command(attrdict({'module': 'module_404'})) captured = capsys.readouterr() assert escape_ansi(captured.out) == 'Module "module_404" does not exist.\n'
async def test_list_command_no_requests(monkeypatch, capsys): monkeypatch.setattr(commands, 'get_requests', lambda: {}) await list_command(attrdict({'module': None})) captured = capsys.readouterr() assert escape_ansi(captured.out) == 'No requests found.\n'
async def test_environments_command_list_environments(capsys, monkeypatch): monkeypatch.setattr(commands, 'get_environments', lambda: ['default', 'another']) await environments_command(attrdict({'environment': None})) captured = capsys.readouterr() assert escape_ansi(captured.out) == '- default\n- another\n'
def test_version_command(capsys): version_command() captured = capsys.readouterr() assert escape_ansi(captured.out) == f'{meta.__version__}\n'