예제 #1
0
 def test_iteration(self, device, device_data):
     for property in device:
         assert pytest.is_unicode_string(property)
     # test that iteration really yields all properties
     device_properties = set(device)
     for property in device_data.properties:
         assert property in device_properties
예제 #2
0
 def test_iteration(self, device, device_data):
     for property in device:
         assert pytest.is_unicode_string(property)
     # test that iteration really yields all properties
     device_properties = set(device)
     for property in device_data.properties:
         assert property in device_properties
예제 #3
0
 def test_iteration(self, device, device_data):
     for attribute in device.attributes:
         assert pytest.is_unicode_string(attribute)
     # check that iteration really yields all attributes
     device_attributes = set(device.attributes)
     for attribute in device_data.attributes:
         assert attribute in device_attributes
예제 #4
0
 def test_iteration(self, device, device_data):
     for attribute in device.attributes:
         assert pytest.is_unicode_string(attribute)
     # check that iteration really yields all attributes
     device_attributes = set(device.attributes)
     for attribute in device_data.attributes:
         assert attribute in device_attributes
예제 #5
0
 def test_sys_number(self, device):
     match = re.search(r'\d+$', device.sys_name)
     # filter out devices with completely nummeric names (first character
     # doesn't count according to the implementation of libudev)
     if match and match.start() > 1:
         assert device.sys_number == match.group(0)
         assert pytest.is_unicode_string(device.sys_name)
     else:
         assert device.sys_number is None
예제 #6
0
 def test_sys_number(self, device):
     match = re.search(r"\d+$", device.sys_name)
     # filter out devices with completely nummeric names (first character
     # doesn't count according to the implementation of libudev)
     if match and match.start() > 1:
         assert device.sys_number == match.group(0)
         assert pytest.is_unicode_string(device.sys_name)
     else:
         assert device.sys_number is None
예제 #7
0
 def test_action_mock(self, device):
     funcname = "udev_device_get_action"
     spec = lambda d: None
     with mock.patch.object(device._libudev, funcname, autospec=spec) as func:
         func.return_value = b"spam"
         assert device.action == "spam"
         func.assert_called_once_with(device)
         func.reset_mock()
         assert pytest.is_unicode_string(device.action)
         func.assert_called_once_with(device)
예제 #8
0
def _is_blacklisted(function):
    for pattern in WRAPPER_BLACKLIST_PATTERNS:
        if pytest.is_unicode_string(pattern):
            if function.name == pattern:
                return True
        else:
            if pattern.match(function.name):
                return True
    else:
        return False
예제 #9
0
def _is_blacklisted(function):
    for pattern in WRAPPER_BLACKLIST_PATTERNS:
        if pytest.is_unicode_string(pattern):
            if function.name == pattern:
                return True
        else:
            if pattern.match(function.name):
                return True
    else:
        return False
예제 #10
0
 def test_action_mock(self, device):
     funcname = 'udev_device_get_action'
     spec = lambda d: None
     with mock.patch.object(device._libudev, funcname,
                            autospec=spec) as func:
         func.return_value = b'spam'
         assert device.action == 'spam'
         func.assert_called_once_with(device)
         func.reset_mock()
         assert pytest.is_unicode_string(device.action)
         func.assert_called_once_with(device)
예제 #11
0
 def test_receive_device_mock(self, monitor):
     receive_device = 'udev_monitor_receive_device'
     get_action = 'udev_device_get_action'
     with pytest.nested(pytest.patch_libudev(receive_device),
                        pytest.patch_libudev(get_action)) as (receive_device,
                                                              get_action):
         receive_device.return_value = mock.sentinel.pointer
         get_action.return_value = b'action'
         action, device = monitor.receive_device()
         assert action == 'action'
         assert pytest.is_unicode_string(action)
         assert isinstance(device, Device)
         assert device.context is monitor.context
         assert device._as_parameter_ is mock.sentinel.pointer
         get_action.assert_called_with(mock.sentinel.pointer)
         receive_device.assert_called_with(monitor)
예제 #12
0
 def test_type(self, device, properties):
     if 'DEVTYPE' in properties:
         assert device.device_type == properties['DEVTYPE']
         assert pytest.is_unicode_string(device.device_type)
     else:
         assert device.device_type is None
예제 #13
0
 def test_iteration(self, device, device_data):
     if not device_data.tags:
         pytest.skip("no tags on device")
     assert set(device.tags) == set(device_data.tags)
     for tag in device.tags:
         assert pytest.is_unicode_string(tag)
예제 #14
0
 def test_device_node(self, device, device_data):
     assert device.device_node == device_data.device_node
     if device.device_node:
         assert pytest.is_unicode_string(device.device_node)
예제 #15
0
 def test_device_node(self, device, device_node):
     if device_node:
         assert device.device_node == device_node
         assert pytest.is_unicode_string(device.device_node)
     else:
         assert device.device_node is None
예제 #16
0
 def test_device_sys_name(self, device):
     assert device.sys_name == os.path.basename(device.device_path)
     assert pytest.is_unicode_string(device.sys_name)
예제 #17
0
 def test_type(self, device, device_data):
     assert device.device_type == device_data.properties.get("DEVTYPE")
     if device.device_type:
         assert pytest.is_unicode_string(device.device_type)
예제 #18
0
 def test_driver(self, device, device_data):
     assert device.driver == device_data.properties.get('DRIVER')
     if device.driver:
         assert pytest.is_unicode_string(device.driver)
예제 #19
0
 def test_iteration(self, device, tags):
     assert set(device.tags) == set(tags)
     assert all(pytest.is_unicode_string(t) for t in device.tags)
예제 #20
0
 def test_asstring(self, device, attributes):
     assert all(pytest.is_unicode_string(device.attributes.asstring(a))
                for a in attributes)
     assert all(device.attributes.asstring(a) == v
                for a, v in attributes.items())
예제 #21
0
 def test_type(self, device, device_data):
     assert device.device_type == device_data.properties.get('DEVTYPE')
     if device.device_type:
         assert pytest.is_unicode_string(device.device_type)
예제 #22
0
 def test_device_sys_name(self, device):
     assert device.sys_name == os.path.basename(device.device_path)
     assert pytest.is_unicode_string(device.sys_name)
예제 #23
0
 def test_subsystem(self, device, device_data):
     assert device.subsystem == device_data.properties['SUBSYSTEM']
     assert pytest.is_unicode_string(device.subsystem)
예제 #24
0
 def test_device_path(self, device, device_data):
     assert device.device_path == device_data.device_path
     assert pytest.is_unicode_string(device.device_path)
예제 #25
0
 def test_device_path(self, context):
     assert pytest.is_unicode_string(context.device_path)
     assert context.device_path == '/dev'
예제 #26
0
 def test_device_node(self, device, device_data):
     assert device.device_node == device_data.device_node
     if device.device_node:
         assert pytest.is_unicode_string(device.device_node)
예제 #27
0
 def test_subsystem(self, device, properties):
     assert device.subsystem == properties['SUBSYSTEM']
     assert pytest.is_unicode_string(device.subsystem)
예제 #28
0
 def test_links(self, context, device, device_data):
     assert sorted(device.device_links) == sorted(device_data.device_links)
     for link in device.device_links:
         assert pytest.is_unicode_string(link)
예제 #29
0
 def test_subsystem(self, device, device_data):
     assert device.subsystem == device_data.properties["SUBSYSTEM"]
     assert pytest.is_unicode_string(device.subsystem)
예제 #30
0
 def test_iteration(self, device, attributes):
     device_attributes = set(device.attributes)
     assert all(a in device_attributes for a in attributes)
     assert all(pytest.is_unicode_string(a) for a in device_attributes)
예제 #31
0
 def test_links(self, context, device, device_links):
     assert sorted(device.device_links) == sorted(
         os.path.join(context.device_path, l) for l in device_links)
     assert all(pytest.is_unicode_string(l) for l in device.device_links)
예제 #32
0
 def test_iteration(self, device, properties):
     device_properties = set(device)
     assert all(p in device_properties for p in properties)
     assert all(pytest.is_unicode_string(p) for p in device_properties)
예제 #33
0
 def test_driver(self, device, device_data):
     assert device.driver == device_data.properties.get("DRIVER")
     if device.driver:
         assert pytest.is_unicode_string(device.driver)
예제 #34
0
파일: test_core.py 프로젝트: csleex/pyudev
 def test_device_path(self, context):
     assert pytest.is_unicode_string(context.device_path)
     assert context.device_path == '/dev'
예제 #35
0
 def test_links(self, context, device, device_data):
     assert sorted(device.device_links) == sorted(device_data.device_links)
     for link in device.device_links:
         assert pytest.is_unicode_string(link)
예제 #36
0
 def test_sys_path(self, device, sys_path):
     assert device.sys_path == sys_path
     assert pytest.is_unicode_string(device.sys_path)
예제 #37
0
 def test_driver(self, device, properties):
     if 'DRIVER' in properties:
         assert device.driver == properties['DRIVER']
         assert pytest.is_unicode_string(device.driver)
     else:
         assert device.driver is None
예제 #38
0
 def test_iteration(self, device, device_data):
     if not device_data.tags:
         pytest.skip('no tags on device')
     assert set(device.tags) == set(device_data.tags)
     for tag in device.tags:
         assert pytest.is_unicode_string(tag)
예제 #39
0
 def test_asstring(self, device, device_data):
     for attribute, value in device_data.attributes.items():
         assert pytest.is_unicode_string(device.attributes.asstring(attribute))
         assert device.attributes.asstring(attribute) == value
예제 #40
0
 def test_action_mock(self, device):
     calls = {'udev_device_get_action': [(device,)]}
     with pytest.calls_to_libudev(calls):
         libudev.udev_device_get_action.return_value = b'spam'
         assert device.action == 'spam'
         assert pytest.is_unicode_string(device.action)
예제 #41
0
 def test_sys_path(self, context):
     assert pytest.is_unicode_string(context.sys_path)
     assert context.sys_path == '/sys'
예제 #42
0
def test_ensure_unicode_string():
    assert pytest.is_unicode_string(
        _util.ensure_unicode_string(b'hello world'))
    assert _util.ensure_unicode_string(b'hello world') == 'hello world'
    hello = 'hello world'
    assert _util.ensure_unicode_string(hello) is hello
예제 #43
0
 def test_run_path(self, context):
     assert pytest.is_unicode_string(context.run_path)
     assert context.run_path == '/run/udev'
예제 #44
0
 def test_device_path(self, device, device_data):
     assert device.device_path == device_data.device_path
     assert pytest.is_unicode_string(device.device_path)
예제 #45
0
파일: test_core.py 프로젝트: csleex/pyudev
 def test_sys_path(self, context):
     assert pytest.is_unicode_string(context.sys_path)
     assert context.sys_path == '/sys'
예제 #46
0
 def test_action_mock(self, device):
     calls = {'udev_device_get_action': [(device, )]}
     with pytest.calls_to_libudev(calls):
         libudev.udev_device_get_action.return_value = b'spam'
         assert device.action == 'spam'
         assert pytest.is_unicode_string(device.action)
예제 #47
0
파일: test_core.py 프로젝트: csleex/pyudev
 def test_run_path(self, context):
     assert pytest.is_unicode_string(context.run_path)
     assert context.run_path == '/run/udev'
예제 #48
0
 def test_asstring(self, device, device_data):
     for attribute, value in device_data.attributes.items():
         assert pytest.is_unicode_string(
             device.attributes.asstring(attribute))
         assert device.attributes.asstring(attribute) == value