test_moderation fails on approved_at date comparison

Bug #890675 reported by blacktavish on 2011-11-15
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
GNU Mailman
Medium
Aamir Khan

Bug Description

Tests fail with

Failure in test test_accepted_message_gets_posted (mailman.app.tests.test_moderation.TestModeration)
Traceback (most recent call last):
  File "/usr/lib64/python2.7/unittest/case.py", line 318, in run
    testMethod()
  File "/home/devel/mailman/src/mailman/app/tests/test_moderation.py", line 83, in test_accepted_message_gets_posted
    'Mon, 01 Aug 2005 07:49:23 -')
  File "/usr/lib64/python2.7/unittest/case.py", line 494, in assertEqual
    assertion_func(first, second, msg=msg)
  File "/usr/lib64/python2.7/unittest/case.py", line 487, in _baseAssertEqual
    raise self.failureException(msg)
AssertionError: 'Mon, 01 Aug 2005 07:49:23 +' != u'Mon, 01 Aug 2005 07:49:23 -'

which seems to include remnants of UTC offset in its comparison

perhaps it should be

mailman/src/mailman/app/tests/test_moderation.py: line 82

        self.assertEqual(message['x-mailman-approved-at'][:-5],
                         'Mon, 01 Aug 2005 07:49:23 ')

blacktavish (blacktavish) wrote :
Barry Warsaw (barry) on 2011-11-15
tags: added: mailman3
Aamir Khan (syst3mw0rm) wrote :

Why is a '-' at the end of date ?

I have changed it to '+' and it works!

But i don't know whether it is correct way to rectify the error.

Barry Warsaw (barry) wrote :

Aamir, the '-' at the end of the date is left over from trying to strip out the timezone information, which will be different everywhere you run the test suite. Because that's unpredictable data, it must be removed from the test output, or you'll get the failure as you've seen. blacktav's diff in comment #1 is the more correct fix for this problem, because it correctly strips off the +- sign, which indicates whether your timezone is east or west of UTC. Because I'm west of UTC, it's negative for me. I'm guessing your east of UTC, so that's why it is positive for you.

This is definitely an easy fix, but here is my suggestion: why don't you create a branch of lp:mailman, apply blacktav's patch and run the test suite to ensure that it fixes the failure. If so, learn how to use bzr to commit the change locally, and then push your branch to Launchpad, using something like lp:~sys3mw0rm/mailman/bug-890675. Then you can use `bzr lp-propose` to submit a merge proposal into trunk. Please include a NEWS.rst file entry (see examples in that file) and please do give due credit to blacktav as well.

Once you've submitted the merge proposal, I'll review it and commit it to trunk. This will give you a great opportunity to learn a bit about the code, and how we accept contributions. Ping me on IRC if you have questions.

Changed in mailman:
status: New → Confirmed
importance: Undecided → Medium
milestone: none → 3.0.0b1
Aamir Khan (syst3mw0rm) on 2012-02-20
Changed in mailman:
assignee: nobody → Aamir Khan (syst3mw0rm)
Barry Warsaw (barry) on 2012-03-13
Changed in mailman:
status: Confirmed → Fix Committed
Barry Warsaw (barry) on 2012-04-06
Changed in mailman:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers