class TestClass(unittest.TestCase):

    def test_some_method_in_case_it_worked(self):
        self.assertEqual(some_method(), True)

def test_some_method_in_case_it_did_not_work(self):
    with mock.patch('__main__.get_object_from_db'
        ) as mocked_get_object_from_db:
        mocked_get_object_from_db.side_effect = RuntimeError('a message')
self.assertEqual(some_method(), False)
if __name__ == '__main__':
    unittest.main()
Как заставить условие гонки в транзакции в тестах django?