Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#12125 closed (fixed)

[patch] The tests for date-based generic views fail in november

Reported by: brutasse Owned by: nobody
Component: Generic views Version: master
Severity: Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In tests/regressiontests/views/tests/generic/date_based.py, line 103:

There is a typo in the prev_month calculation: if the current month is November, then it gets back to the previous year, which should happen in January and not in November.

This behavior makes the test suite fail in November. See the attached trivial patch.

Attachments (1)

previous-month-11696.diff (718 bytes) - added by brutasse 5 years ago.
Patch against trunk, rev11696

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by brutasse

Patch against trunk, rev11696

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Hah. That's been there since April.

comment:2 Changed 5 years ago by kmtracey

  • Resolution set to fixed
  • Status changed from new to closed

(In [11697]) Fixed #12125 -- Fixed a typo in the generic views date_based test that caused it to fail in November. Thanks brutasse.
--This line and those below, will be ignored--

M tests/regressiontests/views/tests/generic/date_based.py

comment:3 Changed 5 years ago by kmtracey

(In [11698]) [1.1.X] (In [11697]) Fixed #12125 -- Fixed a typo in the generic views date_based test that caused it to fail in November. Thanks brutasse.

r11697 from trunk.

comment:4 Changed 5 years ago by sztamas

I've just got this bug myself while running the Django tests, but checked if it's fixed before I raised a bug and found out that it was :)

I don't think that test is very well written.

You should have tests at the boundaries of years with the setUp and assertions values hard-coded (ex. 2004/01/01, 2003/12/01).
I don't see what the value is in a setUp value that changes and then you have to calculate your assertions based on that.
IMHO, it would be better to be able to have fixed the inputs and therefore fixed expectations that you can consistently run without being affected by external factors (like system time).

Note: See TracTickets for help on using tickets.
Back to Top