0

How do I make sure that a certain function raises an exception on certain inputs using mox?

I could do it with try catch but it doesn't seem like too moxxy

Lets say the function is the following:

def merge_paths(a, b):
   if a == "":
      raise RuntimeError("Wrong prefix")
   return a+b
iggy
  • 1,613
  • 1
  • 18
  • 35

1 Answers1

1

I havne't used mox before, but looking at the documentation I guess you're just using this with unittest module?

If so you can do it using assertRaises

self.assertRaises(RuntimeError, merge_paths, a="", b="b")

(self being an instance of unittest.TestCase)

In fact in the first usage example in the mox documentation there is an example of assertRaises.

GP89
  • 6,600
  • 4
  • 36
  • 64