def test_within_pass_utc(): "within(five=miliseconds) gives utc parameter" from sure import within, miliseconds from datetime import datetime def assert_utc(utc): assert isinstance(utc, datetime) within(five=miliseconds)(assert_utc)()
def test_within_fail(): "within(five=miliseconds) will fail" import time from sure import within, miliseconds def sleepy(): time.sleep(0.7) failed = False try: within(five=miliseconds)(sleepy)() except AssertionError, e: failed = True assert_equals('sleepy did not run within five miliseconds', str(e))
def test_within_pass(): "within(five=miliseconds) will pass" from sure import within, miliseconds within(five=miliseconds)(lambda *a: None)()