# 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 os
import stat
import pytest
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
            for key in device_datum.attributes.keys()
        )

    @given(strategies.sampled_from(_DEVICES))
    @settings(max_examples=5)
    def test_getitem_nonexisting(self, a_device):
        """
        Test behavior when corresponding value is non-existant.
        """
        not_key = "a non-existing attribute"
        assert a_device.attributes.get(not_key) is None
        with pytest.raises(KeyError):
            a_device.attributes.asstring(not_key)
        with pytest.raises(KeyError):
            a_device.attributes.asint(not_key)
        with pytest.raises(KeyError):
            a_device.attributes.asbool(not_key)

    @given(strategies.sampled_from(_DEVICES))
    @settings(max_examples=5)
    def test_non_iterable(self, a_device):
        """
        Test that the attributes object can not be iterated over.
        """
        # pylint: disable=pointless-statement
        with pytest.raises(TypeError):
            "key" in a_device.attributes
        with pytest.raises(TypeError):
            a_device.attributes["key"]


# 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/_attributes_tests.py
import os
import stat
import pytest
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

            for key in device_datum.attributes.keys()
        )

    @given(strategies.sampled_from(_DEVICES))
    @settings(max_examples=5)
    def test_getitem_nonexisting(self, a_device):
        """
        Test behavior when corresponding value is non-existant.
        """
        not_key = "a non-existing attribute"
        assert a_device.attributes.get(not_key) is None
        with pytest.raises(KeyError):
            a_device.attributes.asstring(not_key)
        with pytest.raises(KeyError):
            a_device.attributes.asint(not_key)
        with pytest.raises(KeyError):
            a_device.attributes.asbool(not_key)

    @given(strategies.sampled_from(_DEVICES))
    @settings(max_examples=5)
    def test_non_iterable(self, a_device):
        """
        Test that the attributes object can not be iterated over.
        """
        # pylint: disable=pointless-statement
        with pytest.raises(TypeError):
            "key" in a_device.attributes
        with pytest.raises(TypeError):
            a_device.attributes["key"]


    @given(_CONTEXT_STRATEGY, strategies.sampled_from(_DEVICE_DATA))