add test for dt.timer

This commit is contained in:
Prodesire 2018-04-21 20:55:10 +08:00
parent 65eca21c7b
commit 28cc8fe90c
1 changed files with 23 additions and 0 deletions

23
tests/test_dt.py Normal file
View File

@ -0,0 +1,23 @@
import os
from pydu.dt import timer
class TestTimer(object):
def test_context_manager(self):
timeit = timer()
with timeit:
os.getcwd()
assert timeit.elapsed is not None
def test_decorator(self):
import sys
timeit = timer(print_func=print)
@timeit
def foo():
os.getcwd()
foo()
assert timeit.elapsed is not None