Пример #1
0
def test_main(fake_session):
    context = Context()
    context.config = get_fake_valid_config()

    async def fake_async_main(context):
        pass

    async def fake_async_main_with_exception(context):
        raise ScriptWorkerTaskException("This is wrong, the answer is 42")

    with mock.patch("beetmoverscript.script.async_main", new=fake_async_main):
        main(config_path="tests/fake_config.json")

    with mock.patch("beetmoverscript.script.async_main", new=fake_async_main_with_exception):
        try:
            main(config_path="tests/fake_config.json")
        except SystemExit as exc:
            assert exc.code == 1
def test_main(event_loop, fake_session):
    context = Context()
    context.config = get_fake_valid_config()

    async def fake_async_main(context):
        pass

    async def fake_async_main_with_exception(context):
        raise ScriptWorkerTaskException("This is wrong, the answer is 42")

    with mock.patch('beetmoverscript.script.async_main', new=fake_async_main):
        main(name='__main__', config_path='beetmoverscript/test/fake_config.json')

    with mock.patch('beetmoverscript.script.async_main', new=fake_async_main_with_exception):
        try:
            main(name='__main__', config_path='beetmoverscript/test/fake_config.json')
        except SystemExit as exc:
            assert exc.code == 1