File: pytest_fixtures.py

package info (click to toggle)
python-dbusmock 0.38.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 788 kB
  • sloc: python: 6,855; sh: 69; makefile: 4
file content (28 lines) | stat: -rw-r--r-- 724 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
"""pytest fixtures for DBusMock"""

# SPDX-License-Identifier: LGPL-3.0-or-later

__author__ = "Martin Pitt"
__copyright__ = "(c) 2023 Martin Pitt <martin@piware.de>"

from typing import Iterator

import pytest

from dbusmock.testcase import BusType, PrivateDBus


@pytest.fixture(scope="session")
def dbusmock_system() -> Iterator[PrivateDBus]:
    """Export the whole DBusTestCase as a fixture, with the system bus started"""

    with PrivateDBus(BusType.SYSTEM) as bus:
        yield bus


@pytest.fixture(scope="session")
def dbusmock_session() -> Iterator[PrivateDBus]:
    """Export the whole DBusTestCase as a fixture, with the session bus started"""

    with PrivateDBus(BusType.SESSION) as bus:
        yield bus