File: conftest.py

package info (click to toggle)
python-django-split-settings 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 452 kB
  • sloc: python: 292; makefile: 22; sh: 6
file content (55 lines) | stat: -rw-r--r-- 1,303 bytes parent folder | download | duplicates (2)
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
44
45
46
47
48
49
50
51
52
53
54
55
"""This file contains different utils and fixtures."""

import os

import pytest


class Scope(dict):  # noqa: WPS600
    """This class emulates `globals()`, but does not share state in tests."""

    def __init__(self, *args, **kwargs):
        """Adding `__file__` to make things work in `tools.py`."""
        super().__init__(*args, **kwargs)
        self['__file__'] = __file__


# Different util functions:

@pytest.fixture
def scope():
    """This fixture just returns the new instance of the test Scope class."""
    return Scope()


@pytest.fixture
def fixture_file():
    """This fixture return a path to the test fixture file."""
    return os.path.join(
        'settings',
        'basic',
        'fixture_to_include.py',
    )


# Settings files:

@pytest.fixture
def merged():
    """This fixture returns basic merged settings example."""
    from tests.settings import merged as _merged  # noqa: WPS433
    return _merged


@pytest.fixture
def stacked():
    """This fixture returns stacked settings example."""
    from tests.settings import stacked as _stacked  # noqa: WPS433
    return _stacked


@pytest.fixture
def recursion():
    """This fixture returns recursion settings example."""
    from tests.settings import recursion as _recursion  # noqa: WPS433
    return _recursion