← Back to team overview

openstack team mailing list archive

Re: Questions About test_localization.py

 

On Aug 2, 2011, at 4:23 PM, Zed A. Shaw wrote:

> Hi All,
> I'm going to be spending my days for a little while just taking tests
> and source files that haven't been touched in a while and refactoring
> them or cleaning them up.

Awesome.  This should be very helpful.

> The first one I picked was
> tests/test_localization.py, and I've refactored it to be this:
> 
> http://codepad.org/YTODudUt
> 
> It does the same thing, but it's using the Python AST so it's accurate
> about what it's checking and source lines, etc.  It is slower though,
> but about 2 seconds.

:( No one likes slower, but i guess it gives us a chance to do some additional checking.

> 
> Now, after refactoring that, I'm sort of confused about actually what
> this test is doing.  I mean, it's just checking % signs in strings,
> which seems sort of pointless as a gettext check.
> 
> I want to either:
> 
> 1.  Make this confirm that the strings are in gettext, and
> find other strings that should also be in gettext but aren't.

+0 I like finding other strings, although I'm not sure if it is possible to define what "should" be in gettext.  Verifying that the strings are in gettext seems a little bit pointless.
> 
> 2. Get rid of this test as it's not doing much.

-1  The original purpose of the test was that people would add strings with multiple positional replacement strings.  This is hard to translate in some cases, because the translators may need control over word order.  We had a series of 10 or so reviews, which was please convert your positional replacement strings to keyword replacement strings.  After a bunch of reviews, someone finally wrote a test to verify it so we didn't have to repeat it a million times.

The original naive code was fine for that application.  Your refactor is very useful if you want to do some of the things you mentioned in 1., otherwise the existing test was solving the one issue that we had.

> 
> Comments welcome.
> 
> -- 
> Zed A. Shaw
> http://zedshaw.com/
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~openstack
> Post to     : openstack@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~openstack
> More help   : https://help.launchpad.net/ListHelp



Follow ups

References