# Path: tests/utils/udev.py
# class UDevAdm(object):
# class DeviceData(object):
# class DeviceDatabase(collections.abc.Iterable, collections.abc.Sized):
#     CANDIDATES = ["/sbin/udevadm", "udevadm"]
#     def find(cls):
#     def adm(cls):
#     def __init__(self, udevadm):
#     def query_udev_version(self):
#     def _execute(self, *args):
#     def _execute_query(self, device_path, query_type="all"):
#     def query_devices(self):
#     def query_device_properties(self, device_path):
#     def query_device_attributes(self, device_path):
#     def query_device(self, device_path, query_type):
#     def __init__(self, device_path, udevadm):
#     def __repr__(self):
#     def sys_path(self):
#     def exists(self):
#     def properties(self):
#     def attributes(self):
#     def tags(self):
#     def device_node(self):
#     def device_links(self):
#     def device_number(self):
#     def db(cls, renew=False):  # pylint: disable=invalid-name
#     def __init__(self, udevadm):
#     def __iter__(self):
#     def __len__(self):
#     def find_device_data(self, device_path):


import pytest
from hypothesis import strategies
from pyudev import Context, DeviceNotFoundError, Devices
from .utils import udev
        return False


_DEVICE_DATA = [d for d in udev.DeviceDatabase.db()]
_DEVICES = [Devices.from_path(_CONTEXT, d.device_path) for d in _DEVICE_DATA]


def device_strategy(require_existing=True, filter_func=lambda x: True):
    """
    Strategy that yields filtered devices.

    The devices are filtered before being sampled to reduce the number
    of health failures.

    :param bool require_existing: at the very last, verify existance
    :param filter_func: a function to be used as a filter
    :type filter_func: Device -> bool
    """
    strategy = strategies.sampled_from(
        [x for x in _CONTEXT.list_devices() if filter_func(x)]
    )

    if require_existing:
        strategy = strategy.filter(_check_device)

    return strategy


_CONTEXT_STRATEGY = strategies.just(_CONTEXT)


# Path: tests/utils/udev.py
# class UDevAdm(object):
# class DeviceData(object):
# class DeviceDatabase(collections.abc.Iterable, collections.abc.Sized):
#     CANDIDATES = ["/sbin/udevadm", "udevadm"]
#     def find(cls):
#     def adm(cls):
#     def __init__(self, udevadm):
#     def query_udev_version(self):
#     def _execute(self, *args):
#     def _execute_query(self, device_path, query_type="all"):
#     def query_devices(self):
#     def query_device_properties(self, device_path):
#     def query_device_attributes(self, device_path):
#     def query_device(self, device_path, query_type):
#     def __init__(self, device_path, udevadm):
#     def __repr__(self):
#     def sys_path(self):
#     def exists(self):
#     def properties(self):
#     def attributes(self):
#     def tags(self):
#     def device_node(self):
#     def device_links(self):
#     def device_number(self):
#     def db(cls, renew=False):  # pylint: disable=invalid-name
#     def __init__(self, udevadm):
#     def __iter__(self):
#     def __len__(self):
#     def find_device_data(self, device_path):


# Path: tests/_constants.py
import pytest
from hypothesis import strategies
from pyudev import Context, DeviceNotFoundError, Devices
from .utils import udev

        return False


_DEVICE_DATA = [d for d in udev.DeviceDatabase.db()]
_DEVICES = [Devices.from_path(_CONTEXT, d.device_path) for d in _DEVICE_DATA]


def device_strategy(require_existing=True, filter_func=lambda x: True):
    """
    Strategy that yields filtered devices.

    The devices are filtered before being sampled to reduce the number
    of health failures.

    :param bool require_existing: at the very last, verify existance
    :param filter_func: a function to be used as a filter
    :type filter_func: Device -> bool
    """
    strategy = strategies.sampled_from(
        [x for x in _CONTEXT.list_devices() if filter_func(x)]
    )

    if require_existing:
        strategy = strategy.filter(_check_device)

    return strategy


_CONTEXT_STRATEGY = strategies.just(_CONTEXT)


_UDEV_VERSION = int(udev.UDevAdm.adm().query_udev_version())