1

I'd like to test the logic of a program that uses zeep without actually making any external calls. For this, it would be nice to serialize a proper response object, or failing that, be able to construct an object exactly like zeep would.

For example, while I'm online writing tests (serialize and deserialize are the made up functions that I need):

result = zeep.Client(url).service.getFood()
print(food.Flavor)  # prints "bitter"
open('result', 'w').write(result.serialize())

Then later in a unit test run separately

result = zeep.deserialize(open('result').read())
print(food.Flavor) # prints "bitter"

What I've tried:

  • use repr(result) or str(result), but these are native python types and specifically don't support food.Flavor, but food['Flavor']
  • This answer, but I don't really want to mock the whole world, just serialize the response
Johannes Hoff
  • 3,731
  • 5
  • 31
  • 37

0 Answers0