1

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

1 Answer 1

2

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”?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.