9463: Mock usage corrections on a test that was producing failures on other tests
authorLucas Di Pentima <lucas@curoverse.com>
Fri, 5 Aug 2016 20:48:59 +0000 (17:48 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Fri, 5 Aug 2016 20:48:59 +0000 (17:48 -0300)
sdk/python/tests/test_arv_put.py

index 52063f2a153c6f23de0c692c7823b0b2af93f5e9..47594ab952588e635d4c464a77b0177f8189552e 100644 (file)
@@ -478,12 +478,13 @@ class ArvadosPutTest(run_test_server.TestCaseWithServers, ArvadosBaseTestCase):
         coll_save_mock = mock.Mock(name='arv.collection.Collection().save_new()')
         coll_save_mock.side_effect = arvados.errors.ApiError(
             fake_httplib2_response(403), '{}')
-        arvados.collection.Collection.save_new = coll_save_mock
-        with self.assertRaises(SystemExit) as exc_test:
-            self.call_main_with_args(['/dev/null'])
-        self.assertLess(0, exc_test.exception.args[0])
-        self.assertLess(0, coll_save_mock.call_count)
-        self.assertEqual("", self.main_stdout.getvalue())
+        with mock.patch('arvados.collection.Collection.save_new',
+                        new=coll_save_mock):
+            with self.assertRaises(SystemExit) as exc_test:
+                self.call_main_with_args(['/dev/null'])
+            self.assertLess(0, exc_test.exception.args[0])
+            self.assertLess(0, coll_save_mock.call_count)
+            self.assertEqual("", self.main_stdout.getvalue())
 
 
 class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,