-
Notifications
You must be signed in to change notification settings - Fork 0
/
datetimetest.py
45 lines (35 loc) · 894 Bytes
/
datetimetest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from nose.tools import *
import time
# class Customer(object):
# @classmethod
# def create(self):
# customer = Customer()
# customer.created = time.time()
# return customer
# def test_created_time():
# customer = Customer.create()
# time.sleep(3)
# assert_equal(customer.created, time.time())
# class Customer(object):
# @classmethod
# def create(self, time_fn):
# customer = Customer()
# customer.created = time_fn()
# return customer
# def test_created_time():
# now = time.time()
# customer = Customer.create(lambda: now)
# time.sleep(3)
# assert_equal(customer.created, now)
class Customer(object):
@classmethod
def create(self):
customer = Customer()
customer.created = time.time()
return customer
def test_created_time():
now = time.time()
time.sleep(3)
time.time = lambda: now
customer = Customer.create()
assert_equal(customer.created, now)