cros_test_lib_unittest: tweak code for newer mock
Newer versions of mock do not raise errors if you stop a mock more
than once. We were relying on that behavior to throw an exception
for us, so replace the logic with an explicit throw ourselves.
BUG=chromium:1015720
TEST=`./run_tests` passes
Change-Id: Ia023d65209e5be4d5cf646fbac6398e97a0e2777
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/2690932
Reviewed-by: Sergey Frolov <sfrolov@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/lib/cros_test_lib_unittest.py b/lib/cros_test_lib_unittest.py
index f706a5a..19b2cfc 100644
--- a/lib/cros_test_lib_unittest.py
+++ b/lib/cros_test_lib_unittest.py
@@ -190,6 +190,9 @@
patcher.stop()
self.assertEqual(self.Mockable.TO_BE_MOCKED2, -200)
self.assertEqual(self.Mockable.TO_BE_MOCKED3, -300)
+ def abort():
+ raise RuntimeError()
+ patcher.stop = abort
self.assertRaises(RuntimeError, tc.tearDown)
# Make sure that even though exception is raised for stopping 'patcher', we
# continue to stop 'patcher2', and run patcher.stopall().