File: conftest.py

package info (click to toggle)
python-pytest-resource-path 1.3.0-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 192 kB
  • sloc: python: 398; makefile: 4
file content (43 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Implements config for pytest."""
from pathlib import Path

import pytest  # type: ignore

pytest_plugins = "pytester"  # pylint: disable=invalid-name


@pytest.fixture
def testdir_structure(testdir):
    """
    This fixture prepares basic directory structure on testdir.
    This fixture is for testing pytestresource.
    """
    yield from create_directory_structure(testdir, "pytest_code.py")


@pytest.fixture
def testdir_structure_for_testing_resource_path(testdir):
    """
    This fixture prepares basic directory structure on testdir.
    This fixture is for testing pytestresource.
    """
    yield from create_directory_structure(testdir, "pytest_resource_path.py")


@pytest.fixture
def testdir_structure_for_testing_ini(testdir):
    """
    This fixture prepares basic directory structure on testdir.
    This fixture is for testing pytestresource.
    """
    yield from create_directory_structure(testdir, "pytest_resource_path_ini.py", "integrationtests")


def create_directory_structure(testdir, file_name: str, directory_name_tests: str = "tests"):
    """Creates directory structure."""
    testdir.makepyfile(__init__="")
    testdir.mkpydir(directory_name_tests)
    testdir.mkpydir("test_package")
    module_name = directory_name_tests + "/test_package/test_module_something"
    testdir.makepyfile(**{module_name: (Path(__file__).parent / "testresources" / file_name).read_text()})
    yield testdir