# Path: tests/_constants.py
# def _UDEV_TEST(version, node=None):  # pylint: disable=invalid-name
#     fmt_str = "%s: udev version must be at least %s, is %s"
#     return pytest.mark.skipif(
#         _UDEV_VERSION < version, reason=fmt_str % (node, version, _UDEV_VERSION)
#     )
# 
# 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)


import random
import syslog
    import mock
from tests._constants import _UDEV_TEST
from tests.utils import is_unicode_string
from pyudev import udev_version
    from unittest import mock
        assert context.run_path == "/run/udev"

    def test_log_priority_get(self, context):
        assert isinstance(context.log_priority, int)
        assert syslog.LOG_EMERG <= context.log_priority <= syslog.LOG_DEBUG

    def test_log_priority_get_mock(self, context):
        spec = lambda c: None
        funcname = "udev_get_log_priority"
        with mock.patch.object(context._libudev, funcname, autospec=spec) as func:
            func.return_value = mock.sentinel.log_priority
            assert context.log_priority is mock.sentinel.log_priority
            func.assert_called_once_with(context)

    def test_log_priority_set_mock(self, context):
        spec = lambda c, p: None
        funcname = "udev_set_log_priority"
        with mock.patch.object(context._libudev, funcname, autospec=spec) as func:
            context.log_priority = mock.sentinel.log_priority
            func.assert_called_once_with(context, mock.sentinel.log_priority)

    def test_log_priority_roundtrip(self, context):
        # FIXME: This adds UDEV_LOG properties?!
        old_priority = context.log_priority
        available_levels = [
            l
            for l in range(syslog.LOG_EMERG, syslog.LOG_DEBUG + 1)
            if l != old_priority
        ]
        new_priority = random.choice(available_levels)

# Path: tests/_constants.py
# def _UDEV_TEST(version, node=None):  # pylint: disable=invalid-name
#     fmt_str = "%s: udev version must be at least %s, is %s"
#     return pytest.mark.skipif(
#         _UDEV_VERSION < version, reason=fmt_str % (node, version, _UDEV_VERSION)
#     )
# 
# 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/test_core.py
import random
import syslog
    import mock
from tests._constants import _UDEV_TEST
from tests.utils import is_unicode_string
from pyudev import udev_version
    from unittest import mock

        assert context.run_path == "/run/udev"

    def test_log_priority_get(self, context):
        assert isinstance(context.log_priority, int)
        assert syslog.LOG_EMERG <= context.log_priority <= syslog.LOG_DEBUG

    def test_log_priority_get_mock(self, context):
        spec = lambda c: None
        funcname = "udev_get_log_priority"
        with mock.patch.object(context._libudev, funcname, autospec=spec) as func:
            func.return_value = mock.sentinel.log_priority
            assert context.log_priority is mock.sentinel.log_priority
            func.assert_called_once_with(context)

    def test_log_priority_set_mock(self, context):
        spec = lambda c, p: None
        funcname = "udev_set_log_priority"
        with mock.patch.object(context._libudev, funcname, autospec=spec) as func:
            context.log_priority = mock.sentinel.log_priority
            func.assert_called_once_with(context, mock.sentinel.log_priority)

    def test_log_priority_roundtrip(self, context):
        # FIXME: This adds UDEV_LOG properties?!
        old_priority = context.log_priority
        available_levels = [
            l
            for l in range(syslog.LOG_EMERG, syslog.LOG_DEBUG + 1)
            if l != old_priority
        ]
        new_priority = random.choice(available_levels)

        assert new_priority != old_priority