File: conftest.py

package info (click to toggle)
pytest-order 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 600 kB
  • sloc: python: 3,483; makefile: 159; sh: 13
file content (47 lines) | stat: -rw-r--r-- 1,294 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
44
45
46
47
import pytest
from pytest_order.settings import Scope

pytest_plugins = ["pytester"]


@pytest.fixture
def item_names_for(testdir):
    def _item_names_for(tests_content):
        def name(item):
            if item.cls:
                return item.cls.__name__ + "::" + item.name
            return item.name

        items = testdir.getitems(tests_content)
        hook = items[0].config.hook
        hook.pytest_collection_modifyitems(
            session=items[0].session, config=items[0].config, items=items
        )

        return [name(item) for item in items]

    return _item_names_for


@pytest.fixture
def test_path(testdir):
    testdir.tmpdir.join("pytest.ini").write("[pytest]\nconsole_output_style = classic")
    yield testdir


@pytest.fixture
def ignore_settings(mocker):
    settings = mocker.patch("pytest_order.sorter.Settings")
    settings.return_value.sparse_ordering = False
    settings.return_value.order_dependencies = False
    settings.return_value.scope = Scope.SESSION
    settings.return_value.group_scope = Scope.SESSION
    settings.return_value.scope_level = 0
    settings.return_value.marker_prefix = None
    yield settings


@pytest.fixture
def order_dependencies(ignore_settings):
    ignore_settings.return_value.order_dependencies = True
    yield