plugins – Testsuite plugins¶
Plugins to support the pyudev testsuite.
The following plugins are provided and enabled:
pytest namespace¶
The plugin adds the following functions to the pytest namespace:
fake_monitor – A fake Monitor¶
Provide a fake Monitor.
This fake monitor allows to trigger arbitrary events. Use this class to test class building upon monitor without the need to rely on real events generated by privileged operations.
- class plugins.fake_monitor.FakeMonitor(device_to_emit)¶
- A fake - Monitorwhich allows you to trigger arbitrary events.- This fake monitor implements the complete - Monitorinterface and works on real file descriptors so that you can- select()the monitor.- close()¶
- Close sockets acquired by this monitor. 
 - trigger_event()¶
- Trigger an event on clients of this monitor. 
 
Funcargs¶
The plugin provides the following funcargs:
- plugins.fake_monitor.fake_monitor(request)¶
- Return a FakeMonitor, which emits the platform device as returned by the - fake_monitor_devicefuncarg on all triggered actions.- Warning - To use this funcarg, you have to provide the - fake_monitor_devicefuncarg!
mock_libudev – Mock calls to libudev¶
Plugin to mock calls to libudev.
This plugin adds libudev_list() to the pytest namespace.
- plugins.mock_libudev.libudev_list(function, items)¶
- Mock a libudev linked list: - with pytest.libudev_list(device._libudev, 'udev_device_get_tag_list_entry', ['foo', 'bar']): assert list(device.tags) == ['foo', 'bar'] - functionis a string containing the name of the libudev function that returns the list.- itemsis an iterable yielding items which shall be returned by the mocked list function. An item in- itemscan either be a tuple with two components, where the first component is the item name, and the second the item value, or a single element, which is the item name. The item value is- Nonein this case.
travis – Support for Travis CI¶
Support for Travis CI.
Test markers¶
- pytest.mark.not_on_travis¶
- Do not run the decorated test on Travis CI: - @pytest.mark.not_on_travis def test_foo(): assert True - test_foowill not be run on Travis CI.
pytest namespace¶
The plugin adds the following functions to the pytest namespace:
- plugins.travis.is_on_travis_ci()¶
- Determine whether the tests run on Travis CI. - Return - True, if so, or- Falseotherwise.