[Twisted-Python] Failing tests in trunk

Facundo Batista facundobatista at gmail.com
Thu Mar 10 14:39:58 EST 2011


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].

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)

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).

Ideas? Opinions?

Thanks!

(BTW, I'm already at PyCon :D )


[0] Which I easily tested in a clean Python interpreter:

    >>> import locale
    >>> locale.getlocale()
    (None, None)
    >>> import gtk
    >>> locale.getlocale()
    ('es_AR', 'UTF8')

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/



More information about the Twisted-Python mailing list