Skip to content

Commit

Permalink
fixed time module call
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkerns committed Mar 14, 2015
1 parent b95dfc5 commit adca1f0
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tests/core/test_decorators.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import unittest
from time import sleep, time

from pylinac.core.decorators import *

Expand Down Expand Up @@ -61,20 +60,20 @@ def test_lazyproperty(self):
class ExpensiveClass:
@lazyproperty
def expensive_property(self):
sleep(0.2)
time.sleep(0.2)
return
ec = ExpensiveClass()

# run the expensive property for the first time
start = time()
start = time.time()
_ = ec.expensive_property
end = time()
end = time.time()
first_access_time = end - start

# run it for the second time; should access cached property
start = time()
start = time.time()
_ = ec.expensive_property
end = time()
end = time.time()
cached_access_time = end - start

self.assertLess(cached_access_time, first_access_time)
Expand Down

0 comments on commit adca1f0

Please sign in to comment.