Example #1
0
def main():
    """
    Main method, works infinitely until user runs `exit` command.
    Or hits `Ctrl+C` in the console.
    """
    while True:
        try:
            perform_command(parse_user_input())
        except UserExitException:
            break
        except Exception as ex:
            print('You have done something wrong!', ex)
def test_command_execution(monkeypatch):
    from todo.commands import UndoneCommand
    from todo.runtime import perform_command
    from todo.models import Storage, ToDoItem

    monkeypatch.setitem(__builtins__, 'input', lambda _: 0)

    item = ToDoItem('test')
    item.done = True

    s = Storage()
    s.items.clear()
    s.items.append(item)

    perform_command(UndoneCommand().label)

    assert item.done is False