Ejemplo n.º 1
0
 def test_clear(self):
     lazy_constant = ThreadLocalLazyConstant(qcore.utime)
     lazy_time = lazy_constant.get_value()
     with qcore.TimeOffset(qcore.HOUR):
         assert_eq(lazy_time,
                   lazy_constant.get_value(),
                   tolerance=qcore.MINUTE)
         lazy_constant.clear()
         assert_ne(lazy_time,
                   lazy_constant.get_value(),
                   tolerance=qcore.MINUTE)
Ejemplo n.º 2
0
 def test_not_compute(self):
     lazy_constant = ThreadLocalLazyConstant(lambda: not_computed)
     assert_is(None, lazy_constant.compute())
     assert_is(None, lazy_constant.get_value())
Ejemplo n.º 3
0
 def execute():
     with lock:
         results.append(lazy_constant.get_value())