Changeset View
Changeset View
Standalone View
Standalone View
swh/scanner/tests/conftest.py
Show All 35 Lines | |||||
@pytest.fixture | @pytest.fixture | ||||
async def aiosession(): | async def aiosession(): | ||||
"""Fixture that generate an aiohttp Client Session.""" | """Fixture that generate an aiohttp Client Session.""" | ||||
session = aiohttp.ClientSession() | session = aiohttp.ClientSession() | ||||
yield session | yield session | ||||
session.detach() | session.detach() | ||||
@pytest.fixture(scope="session") | @pytest.fixture(scope="function") | ||||
def temp_folder(tmp_path_factory): | def temp_folder(tmp_path): | ||||
"""Fixture that generates a temporary folder with the following | """Fixture that generates a temporary folder with the following | ||||
structure: | structure: | ||||
.. code-block:: python | .. code-block:: python | ||||
root = { | root = { | ||||
subdir: { | subdir: { | ||||
subsubdir | subsubdir | ||||
filesample.txt | filesample.txt | ||||
filesample2.txt | filesample2.txt | ||||
} | } | ||||
subdir2 | subdir2 | ||||
subfile.txt | subfile.txt | ||||
} | } | ||||
""" | """ | ||||
root = tmp_path_factory.getbasetemp() | root = tmp_path | ||||
subdir = tmp_path_factory.mktemp("subdir") | subdir = root / "subdir" | ||||
subsubdir = subdir.joinpath("subsubdir") | subdir.mkdir() | ||||
subsubdir = subdir / "subsubdir" | |||||
subsubdir.mkdir() | subsubdir.mkdir() | ||||
subdir2 = tmp_path_factory.mktemp("subdir2") | subdir2 = root / "subdir2" | ||||
subdir2.mkdir() | |||||
subfile = root / "subfile.txt" | subfile = root / "subfile.txt" | ||||
subfile.touch() | subfile.touch() | ||||
filesample = subdir / "filesample.txt" | filesample = subdir / "filesample.txt" | ||||
filesample.touch() | filesample.touch() | ||||
filesample2 = subdir / "filesample2.txt" | filesample2 = subdir / "filesample2.txt" | ||||
filesample2.touch() | filesample2.touch() | ||||
avail_path = { | avail_path = { | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |