File: pytest_fixtures.py

package info (click to toggle)
python-dbusmock 0.36.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 812 kB
  • sloc: python: 7,324; sh: 73; makefile: 4
file content (32 lines) | stat: -rw-r--r-- 1,013 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
"""pytest fixtures for DBusMock"""

# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option) any
# later version.  See http://www.gnu.org/copyleft/lgpl.html for the full text
# of the license.

__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