Reputation: 677
I am writing unit tests for functions in python which get and set xml data from/to the hardware's firmware. How can i mock such things. I am using python and nose
Upvotes: 1
Views: 367
Reputation: 7275
I haven't written a ton of Python, but the concept will apply from other languages.
The idea is to create an abstraction over the XML data from the hardware. In C# or Java you would use an interface.
Once you have an interface in place you can have many different implementations of it. You can have an implementation that talks to the hardware (for production) and one that is mocked.
That way you can run your tests even if the hardware is not available.
This sounds like what you'd want in Python: What's the Python version for “Code against an interface, not an object”?
Upvotes: 2