[Twisted-Python] Failing tests in trunk

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Thu Mar 10 21:51:32 EST 2011


On 10 Mar, 07:39 pm, facundobatista at gmail.com wrote:
>On Tue, Mar 8, 2011 at 7:04 AM, Facundo Batista
><facundobatista at gmail.com> wrote:
>>>None of these are known failures:
>>>
>>>   http://buildbot.twistedmatrix.com/boxes-supported
>>>
>>>Just looking at the list of failing tests, I would make a small bet 
>>>that
>>>the failures are caused by your locale setting somehow.
>>
>>I thought of that, but why would the test pass when running alone?
>>
>>I'll debug this.
>
>Ok, found it.
>
>See one example of the test that failed,
>twisted.mail.test.test_imap.NewFetchTestCase.testFetchInternalDate:
>
>    twisted.trial.unittest.FailTest: not equal:
>    a = {0: {'INTERNALDATE': '02-nov-2003 21:25:10 +0000'},
>     1: {'INTERNALDATE': '29-dic-2013 11:31:52 -0500'},
>     2: {'INTERNALDATE': '10-mar-1992 02:44:30 -0600'},
>     3: {'INTERNALDATE': '11-ene-2000 14:40:24 -0800'}}
>    b = {0: {'INTERNALDATE': '02-Nov-2003 21:25:10 +0000'},
>     1: {'INTERNALDATE': '29-Dec-2013 11:31:52 -0500'},
>     2: {'INTERNALDATE': '10-Mar-1992 02:44:30 -0600'},
>     3: {'INTERNALDATE': '11-Jan-2000 14:40:24 -0800'}}
>
>See the difference? "nov" instead of "Nov", etc. "dic" instead of
>"Dec". Yes, in Spanish December is 'diciembre'.
>
>So, funny 'locale' issue, confirmed by showing getlocale() in the
>test... when running the whole suite, the locale is ('es_AR', 'UTF8'),
>and when running twisted.mail the locale is (None, None).
>
>Weird, specially taking into account that 'locale' is not used in the
>whole twisted project.
>
>But I tracked it down.
>
>In twisted/manhole/ui/test/test_gtk2manhole.py, gtk is imported, and
>that changes the locale [0].

Aha, nicely done.  I figured the locale change would be in Python 
somewhere, I didn't consider it might be hidden in Gtk.
>So, how this can be fixed?
>
>Is ok for the IMAP4Server to spew the message internal date according
>to the locale in which it's being run? Or it should always format the
>dates in an specific way, because some definition somewhere? (I don't
>know much about IMAP)

IMAP specifies the strings in the unit test.  So the implementation 
really needs to change to not depend on the locale.
>If it's ok for the server to format the dates according to the locale,
>I should make the test more robust. If not, the server should set the
>locale to (None, None) for the date formatting, or just set it at
>__init__ and leave it there, or use other formatting (not
>time.strftime, I prefer this solution).

I agree with your preference, switching away from time.strftime is 
probably the right thing to do.

Jean-Paul



More information about the Twisted-Python mailing list