runtests throws an exception because of clash between gettext and doctest

Bug #655383 reported by David D Lowe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
wxBanker
Fix Released
Low
Michael Rooney

Bug Description

I have language support for French and Russian installed through Ubuntu's "Language Support" tool. I'm running from source, trunk revno 829. Running the following command from the root of the branch gives me the following output:

$ python -m wxbanker/runtests
DOCTESTS:**********************************************************************
File "wxbanker/controller.py", line 66, in wxbanker.controller
Failed example:
    model.float2str(model.Balance)
Expected:
    u'$90.27'
Got:
    u'\xa390.27'
**********************************************************************
File "wxbanker/controller.py", line 75, in wxbanker.controller
Failed example:
    model.float2str(model.Balance)
Expected:
    u'-$111.00'
Got:
    u'-\xa3111.00'
**********************************************************************
1 items had failures:
   2 of 60 in wxbanker.controller
***Test Failed*** 2 failures.
TestResults(failed=2, attempted=60)
Traceback (most recent call last):
  File "/usr/lib/python2.6/runpy.py", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.6/runpy.py", line 34, in _run_code
    exec code in run_globals
  File "/home/david/Programming/wxbanker/trunk/wxbanker/runtests.py", line 39, in <module>
    main()
  File "/home/david/Programming/wxbanker/trunk/wxbanker/runtests.py", line 32, in main
    alltests.main()
  File "wxbanker/tests/alltests.py", line 35, in main
    suite = unittest.TestLoader().loadTestsFromNames(modules)
  File "/usr/lib/python2.6/unittest.py", line 613, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.6/unittest.py", line 576, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "wxbanker/tests/localetests.py", line 55, in <module>
    assertLocale(loc)
  File "wxbanker/tests/localetests.py", line 29, in assertLocale
    reload(currencies)
  File "wxbanker/currencies.py", line 334, in <module>
    CurrencyStrings[0] += " (%s)" % _("detected")
TypeError: 'bool' object is not callable

I suspect this is because of the well-known clash between doctest and gettext.

Revision history for this message
David D Lowe (flimm) wrote :

I edited line 334 in wxbanker/currencies.py to become:

CurrencySttrings[0] += " (%s)" % "detected"

I received the attached output.

summary: - Test fail because of clash between gettext and doctest
+ runtests throws an exception because of clash between gettext and
+ doctest
Revision history for this message
Michael Rooney (mrooney) wrote :

Hm, I'm getting "TypeError: 'bool' object is not callable" as well (but not the doctests error, what is your system locale? The tests assume en_US I believe), but I swore it was working just the other night, how odd.

Anyway, the doctests are really legacy tests, in the mean time you should be able to just run the unit tests: python wxbanker/tests/alltests.py

Changed in wxbanker:
status: New → Confirmed
Revision history for this message
David D Lowe (flimm) wrote :

I don't get the doctest errors when I set the environment variable LANG to en_US.utf8.

Revision history for this message
Michael Rooney (mrooney) wrote :

I can't reproduce this any more on a fresh checkout, can you (with en_US locale)?

Changed in wxbanker:
status: Confirmed → Incomplete
Revision history for this message
David D Lowe (flimm) wrote :

I can still reproduce this with trunk revno:829. (Is that what you mean by a fresh checkout?)

Revision history for this message
Michael Rooney (mrooney) wrote :

I see, it seems to be happening in Maverick but not Lucid, how odd. Are you running Maverick? I wonder if it is a Python 2.6.6 change, or something else.

Revision history for this message
David D Lowe (flimm) wrote :

Yes, I'm running Maverick.

Changed in wxbanker:
status: Incomplete → New
Revision history for this message
Michael Rooney (mrooney) wrote :

Okay, I'm not sure why that was happening since I was overriding the display hook which works fine in Lucid, but that's fine. I looked over the doctests and I am pretty sure the unit tests cover everything they do and more, in a better way (I can't remember the last time the doctests found a regression), so I just deleted them as well as runtests.py and testhelpers.py which aren't needed anymore. So now it will work as before: python wxbanker/tests/alltests.py

I'll also add a check that the tests are running under en_US.utf8 and attempt to set that first, to avoid the other failures.

Thanks for finding this and prompting me to do some cleanup!

Changed in wxbanker:
assignee: nobody → Michael Rooney (mrooney)
importance: Undecided → Low
milestone: none → 0.9
status: New → Fix Committed
Michael Rooney (mrooney)
Changed in wxbanker:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.