diff options
author | Stephen Finucane <stephenfin@redhat.com> | 2023-03-22 12:22:03 +0000 |
---|---|---|
committer | Stephen Finucane <stephenfin@redhat.com> | 2023-04-17 10:17:35 +0100 |
commit | 672dd056aa66645648c0d71af5eae3da9f424e48 (patch) | |
tree | 19bd1a7dd5342ab1088b281ccf48755d7fa45301 | |
parent | 481936a822425c6a8c806409c8c877eed6661a2c (diff) | |
download | oslo-db-672dd056aa66645648c0d71af5eae3da9f424e48.tar.gz |
Don't sleep in tests
Mock it out, reducing test run of ~3 and ~15 seconds to milliseconds.
Change-Id: Ice3a0c0d0a5b8c2920c7f775ff8ce974b572c66e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
-rw-r--r-- | oslo_db/tests/test_api.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/oslo_db/tests/test_api.py b/oslo_db/tests/test_api.py index 2540780..d45dce6 100644 --- a/oslo_db/tests/test_api.py +++ b/oslo_db/tests/test_api.py @@ -210,7 +210,8 @@ class DBRetryRequestCase(DBAPITestCase): some_method() - def test_retry_wrapper_reaches_limit(self): + @mock.patch('oslo_db.api.time.sleep', return_value=None) + def test_retry_wrapper_reaches_limit(self, mock_sleep): max_retries = 2 @api.wrap_db_retry(max_retries=max_retries) @@ -222,7 +223,8 @@ class DBRetryRequestCase(DBAPITestCase): self.assertRaises(ValueError, some_method, res) self.assertEqual(max_retries + 1, res['result']) - def test_retry_wrapper_exception_checker(self): + @mock.patch('oslo_db.api.time.sleep', return_value=None) + def test_retry_wrapper_exception_checker(self, mock_sleep): def exception_checker(exc): return isinstance(exc, ValueError) and exc.args[0] < 5 |