diff options
| author | Nick Pope <nick.pope@flightdataservices.com> | 2020-07-29 15:18:13 +0100 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-10-16 13:13:15 +0200 |
| commit | 177a49e79c882603da64d45995f5fd60dce8c852 (patch) | |
| tree | 5bc800cc89dc32fe0a83c077cd015c9ce529eb15 /tests/cache | |
| parent | be183fc94ffa6d9dbefb4faac915f8aad34fc4b7 (diff) | |
Reduced time.sleep() in cache touch() tests.
There are 8 cache backends to test and each test of touch() takes
~7s → ~56s. This seems excessive and it feels like we should be able
to reduce this significantly. time.sleep() accepts floating point
values and is guaranteed to sleep for at least the number of seconds
specified as of Python 3.5.
We do run the risk that there may be spurious test failures from this,
but that already seemed to be the case anyway.
Diffstat (limited to 'tests/cache')
| -rw-r--r-- | tests/cache/tests.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/cache/tests.py b/tests/cache/tests.py index 1ef2cc1bc1..2a3bf57354 100644 --- a/tests/cache/tests.py +++ b/tests/cache/tests.py @@ -440,15 +440,15 @@ class BaseCacheTests: def test_touch(self): # cache.touch() updates the timeout. cache.set('expire1', 'very quickly', timeout=1) - self.assertIs(cache.touch('expire1', timeout=4), True) - time.sleep(2) + self.assertIs(cache.touch('expire1', timeout=2), True) + time.sleep(1.0) self.assertIs(cache.has_key('expire1'), True) - time.sleep(3) + time.sleep(1.5) self.assertIs(cache.has_key('expire1'), False) # cache.touch() works without the timeout argument. cache.set('expire1', 'very quickly', timeout=1) self.assertIs(cache.touch('expire1'), True) - time.sleep(2) + time.sleep(1.5) self.assertIs(cache.has_key('expire1'), True) self.assertIs(cache.touch('nonexistent'), False) |
