summaryrefslogtreecommitdiffstats
path: root/tests/conftest.py
blob: 93576d6329e34cca7f3665964226a5a06f05024f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from pathlib import Path
from unittest.mock import MagicMock

TEST_DIR = Path(__file__).parents[0]


def fullpath(fname: str):
    return str(TEST_DIR / fname)


PATH_FNAME = fullpath('mock_path_file')
PATH_FNAME_EMPTY = fullpath('empty_path_file')
PATH_FNAME_CLASH = fullpath('clash_path_file')
PATH_FNAME_MAIN = fullpath('main_path_file')
GROUP_FNAME = fullpath('mock_group_file')

def async_mock():
    """
    Mock an async function. The calling arguments are saved in a MagicMock.
    """
    m = MagicMock()

    async def coro(*args, **kwargs):
        return m(*args, **kwargs)

    coro.mock = m
    return coro