runtests throws an exception because of clash between gettext and doctest

Bug #655383 reported by David D Lowe on 2010-10-05
This bug affects 1 person
Affects Status Importance Assigned to Milestone
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
File "wxbanker/", line 66, in wxbanker.controller
Failed example:
File "wxbanker/", line 75, in wxbanker.controller
Failed example:
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/", line 122, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.6/", line 34, in _run_code
    exec code in run_globals
  File "/home/david/Programming/wxbanker/trunk/wxbanker/", line 39, in <module>
  File "/home/david/Programming/wxbanker/trunk/wxbanker/", line 32, in main
  File "wxbanker/tests/", line 35, in main
    suite = unittest.TestLoader().loadTestsFromNames(modules)
  File "/usr/lib/python2.6/", line 613, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/lib/python2.6/", line 576, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "wxbanker/tests/", line 55, in <module>
  File "wxbanker/tests/", line 29, in assertLocale
  File "wxbanker/", 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.

David D Lowe (flimm) wrote :

I edited line 334 in wxbanker/ 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
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/

Changed in wxbanker:
status: New → Confirmed
David D Lowe (flimm) wrote :

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

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
David D Lowe (flimm) wrote :

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

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.

David D Lowe (flimm) wrote :

Yes, I'm running Maverick.

Changed in wxbanker:
status: Incomplete → New
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 and which aren't needed anymore. So now it will work as before: python wxbanker/tests/

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) on 2013-11-20
Changed in wxbanker:
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

Bug attachments