# Path: tests/utils/misc.py
# def is_unicode_string(value):
#     """
#     Return ``True``, if ``value`` is of a real unicode string type
#     (``unicode`` in python 2, ``str`` in python 3), ``False`` otherwise.
#     """
#     return isinstance(value, str)
# 
# Path: tests/_device_tests/_device_tests.py
# class TestDevice(object):
#     def test_parent(self, a_device):
#     def test_child_of_parent(self, a_device):
#     def test_children(self, a_device):
#     def test_ancestors(self, a_device):
#     def test_find_parent(self, a_device):
#     def test_find_parent_no_devtype_mock(self, a_device):
#     def test_find_parent_with_devtype_mock(self, a_device):
#     def test_traverse(self, a_device):
#     def test_sys_path(self, a_context, device_datum):
#     def test_device_path(self, a_context, device_datum):
#     def test_subsystem(self, a_context, device_datum):
#     def test_device_sys_name(self, a_device):
#     def test_sys_number(self, a_device):
#     def test_type(self, a_context, device_datum):
#     def test_driver(self, a_context, device_datum):
#     def test_device_node(self, a_context, device_datum):
#     def test_device_number(self, a_context, device_datum):
#     def test_is_initialized(self, a_device):
#     def test_is_initialized_mock(self, a_device):
#     def test_time_since_initialized(self, a_device):
#     def test_time_since_initialized_mock(self, a_device):
#     def test_links(self, a_context, device_datum):
#     def test_action(self, a_device):
#     def test_action_mock(self, a_device):
#     def test_sequence_number(self, a_device):
#     def test_attributes(self, a_device):
#     def test_no_leak(self):
#     def test_tags(self, a_device):
#     def test_iteration(self, a_context, device_datum):
#     def test_length(self, a_context, device_datum):
#     def test_key_subset(self, a_context, device_datum):
#     def test_getitem(self, a_context, device_datum):
#     def test_getitem_devname(self, a_context, device_datum):
#     def test_getitem_nonexisting(self, a_device):
#     def test_asint(self, a_context, device_datum):
#     def test_asbool(self, a_context, device_datum):
#     def test_hash(self, a_device):
#     def test_equality(self, a_device):
#     def test_inequality(self, a_device):
#     def test_device_ordering(self, a_device):
#     def test_id_wwn_with_extension(self, a_device):


import pytest
    import mock
from hypothesis import given, settings, strategies
from pyudev import Devices
from ..utils import is_unicode_string
from ._device_tests import _CONTEXT_STRATEGY, _DEVICE_DATA, _DEVICES, _UDEV_TEST
    from unittest import mock
    """
    Test methods of the ``Tags`` class.
    """

    pytestmark = _UDEV_TEST(154, "TestTags")

    _device_data = [d for d in _DEVICE_DATA if d.tags]

    @pytest.mark.skipif(len(_device_data) == 0, reason="no device with tags")
    @given(_CONTEXT_STRATEGY, strategies.sampled_from(_device_data))
    @settings(max_examples=5)
    def test_iteration_and_contains(self, a_context, device_datum):
        """
        Test that iteration yields all tags and contains checks them.
        """
        device = Devices.from_path(a_context, device_datum.device_path)
        assert frozenset(device.tags) == frozenset(device_datum.tags)
        assert all(is_unicode_string(tag) for tag in device.tags)

    @given(strategies.sampled_from(_DEVICES))
    @settings(max_examples=5)
    def test_iteration_mock(self, a_device):
        funcname = "udev_device_get_tags_list_entry"
        with pytest.libudev_list(a_device._libudev, funcname, [b"spam", b"eggs"]):
            tags = list(a_device.tags)
            assert tags == ["spam", "eggs"]
            func = a_device._libudev.udev_device_get_tags_list_entry
            func.assert_called_once_with(a_device)

    @_UDEV_TEST(172, "test_contans_mock")

# Path: tests/utils/misc.py
# def is_unicode_string(value):
#     """
#     Return ``True``, if ``value`` is of a real unicode string type
#     (``unicode`` in python 2, ``str`` in python 3), ``False`` otherwise.
#     """
#     return isinstance(value, str)
# 
# Path: tests/_device_tests/_device_tests.py
# class TestDevice(object):
#     def test_parent(self, a_device):
#     def test_child_of_parent(self, a_device):
#     def test_children(self, a_device):
#     def test_ancestors(self, a_device):
#     def test_find_parent(self, a_device):
#     def test_find_parent_no_devtype_mock(self, a_device):
#     def test_find_parent_with_devtype_mock(self, a_device):
#     def test_traverse(self, a_device):
#     def test_sys_path(self, a_context, device_datum):
#     def test_device_path(self, a_context, device_datum):
#     def test_subsystem(self, a_context, device_datum):
#     def test_device_sys_name(self, a_device):
#     def test_sys_number(self, a_device):
#     def test_type(self, a_context, device_datum):
#     def test_driver(self, a_context, device_datum):
#     def test_device_node(self, a_context, device_datum):
#     def test_device_number(self, a_context, device_datum):
#     def test_is_initialized(self, a_device):
#     def test_is_initialized_mock(self, a_device):
#     def test_time_since_initialized(self, a_device):
#     def test_time_since_initialized_mock(self, a_device):
#     def test_links(self, a_context, device_datum):
#     def test_action(self, a_device):
#     def test_action_mock(self, a_device):
#     def test_sequence_number(self, a_device):
#     def test_attributes(self, a_device):
#     def test_no_leak(self):
#     def test_tags(self, a_device):
#     def test_iteration(self, a_context, device_datum):
#     def test_length(self, a_context, device_datum):
#     def test_key_subset(self, a_context, device_datum):
#     def test_getitem(self, a_context, device_datum):
#     def test_getitem_devname(self, a_context, device_datum):
#     def test_getitem_nonexisting(self, a_device):
#     def test_asint(self, a_context, device_datum):
#     def test_asbool(self, a_context, device_datum):
#     def test_hash(self, a_device):
#     def test_equality(self, a_device):
#     def test_inequality(self, a_device):
#     def test_device_ordering(self, a_device):
#     def test_id_wwn_with_extension(self, a_device):


# Path: tests/_device_tests/_tags_tests.py
import pytest
    import mock
from hypothesis import given, settings, strategies
from pyudev import Devices
from ..utils import is_unicode_string
from ._device_tests import _CONTEXT_STRATEGY, _DEVICE_DATA, _DEVICES, _UDEV_TEST
    from unittest import mock

    """
    Test methods of the ``Tags`` class.
    """

    pytestmark = _UDEV_TEST(154, "TestTags")

    _device_data = [d for d in _DEVICE_DATA if d.tags]

    @pytest.mark.skipif(len(_device_data) == 0, reason="no device with tags")
    @given(_CONTEXT_STRATEGY, strategies.sampled_from(_device_data))
    @settings(max_examples=5)
    def test_iteration_and_contains(self, a_context, device_datum):
        """
        Test that iteration yields all tags and contains checks them.
        """
        device = Devices.from_path(a_context, device_datum.device_path)
        assert frozenset(device.tags) == frozenset(device_datum.tags)
        assert all(is_unicode_string(tag) for tag in device.tags)

    @given(strategies.sampled_from(_DEVICES))
    @settings(max_examples=5)
    def test_iteration_mock(self, a_device):
        funcname = "udev_device_get_tags_list_entry"
        with pytest.libudev_list(a_device._libudev, funcname, [b"spam", b"eggs"]):
            tags = list(a_device.tags)
            assert tags == ["spam", "eggs"]
            func = a_device._libudev.udev_device_get_tags_list_entry
            func.assert_called_once_with(a_device)

    @_UDEV_TEST(172, "test_contans_mock")

    @given(strategies.sampled_from(_DEVICES))