From 48b52b76f28108493b180be39fa3742d16468ad7 Mon Sep 17 00:00:00 2001 From: Jakub Stasiak Date: Tue, 11 Jun 2013 16:00:48 +0100 Subject: [PATCH] Make thread safety tests faster --- injector_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/injector_test.py b/injector_test.py index 0a00e94..1f835eb 100644 --- a/injector_test.py +++ b/injector_test.py @@ -782,8 +782,10 @@ def test_assisted_builder_injection_uses_the_same_binding_key_every_time(): class TestThreadSafety(object): def setup(self): + self.event = threading.Event() + def configure(binder): - binder.bind(str, to=lambda: sleep(1) and 'this is str') + binder.bind(str, to=lambda: self.event.wait() and 'this is str') class XXX(object): @inject(s=str) @@ -807,6 +809,8 @@ class TestThreadSafety(object): for t in threads: t.start() + self.event.set() + for t in threads: t.join()