#30886 closed Uncategorized (invalid)
Bug in TestCase tutorial
Reported by: | Jan Zimmermann | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 2.2 |
Severity: | Normal | Keywords: | TestCase |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
in https://docs.djangoproject.com/en/2.2/intro/tutorial05/
you create a function to create a Question object
def create_question(question_text, days): """ 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() + datetime.timedelta(days=days) return Question.objects.create(question_text=question_text, pub_date=time)
But there is no save() call. when testing the polls app it always returns an empty query set which leads to a failed assertQuerysetEqual()
Change History (2)
comment:1 by , 5 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 5 years ago
Sorry i'm an idiot. i searched for hours and didn't see that i used Question() constructor instead of Question.objects.create()
thanks.
Note:
See TracTickets
for help on using tickets.
You don't need to call
save()
afterQuerySet.create()
(see documentation).