From 755f917a16f002a29a8bd3b38c0b70aea44c6dc6 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 3 Nov 2015 00:17:37 +0100 Subject: [PATCH] tests: fix test_store_async (#8847) Test can fail if atomic_write() is slow, but behaviour is correct. Foobar.keys() will always return a non True value as the file first created by get_new_id(create=True) and not by atomic_write(). --- tests/test_storage.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_storage.py b/tests/test_storage.py index aefc3f1..0321857 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -332,8 +332,13 @@ def test_store_async(): test.unique_value = 'unique-value' test.store(async=True) t0 = time.time() - while not Foobar.keys(): + while True: time.sleep(0.1) + try: + test = Foobar.get(1) + break + except KeyError: + pass if time.time()-t0 > 2: raise Exception('timeout') test = Foobar.get(1) -- 2.1.4