ku-polls/polls/tests/base.py
2023-09-18 00:11:35 +07:00

14 lines
480 B
Python

from django.utils import timezone
from ..models import Question
def create_question(question_text, day=0):
"""
Create a question with the given `question_text` and published the
given number of `days` offset to now (negative for questions published
in the past, positive for questions that have yet to be published).
"""
time = timezone.now() + timezone.timedelta(days=day)
return Question.objects.create(question_text=question_text, pub_date=time)