Search code examples
pythonunit-testingdbushal

Unit testing for D-Bus and HAL?


How does one test a method that does some interactions with the local D-Bus (accessing a HAL object)?

Results of tests will differ depending on the system that the test is run on, so I don't know how to provide the method reliable input.

I'm working in Python, by the way.


Solution

  • If you can not mock the environment then it's probably impossible for you to write the test. If your access to HAL/D-Bus is via an object and you provide a mock instance to your test then it should be possible to emulate the necessary inputs to your test from the mock implementation.