Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Software Testing) expand_more
Software Testing / Test Doubles & Dependencies

time control with fake clock

Learn time control with fake clock in Software Testing with a dedicated explanation, a concept-specific example, practical cautions, and a mastery check.

12 min read • Intermediate
software-testing-021.py
python
from datetime import datetime
class Clock:
    def now(self): return datetime(2026,1,1,9,0,0)
def greeting(clock): return 'morning' if clock.now().hour<12 else 'later'
assert greeting(Clock())=='morning'
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content