[GRASS-dev] failing doctest when delete temporal dataset
Vaclav Petras
wenzeslaus at gmail.com
Thu Feb 18 07:02:06 PST 2016
On Thu, Feb 18, 2016 at 5:49 AM, Luca Delucchi <lucadeluge at gmail.com> wrote:
> I get the following error, but if I run the python
> code of the test I get not error. Do you have any idea how to solve
> it?
>
> self.msgr.verbose(_("Delete space time %s dataset <%s> from
> temporal "
> TypeError: 'int' object is not callable
>
This happens when the tested method uses translatable stings (usually for
message or in case of error - which might be part of testing).
The reason is that underscore is used in interactive interpreter for the
"last result" and this is inherited by doctest and at the same time, GRASS
is using _ for translation and setting is as buildin. There is a ticked
proposing imports instead of buildin [1]. I already implemented this for
wxGUI few years back (for GUI you now have to explicitly import _ function
[2]). To my understanding, this should avoid the clash of two different
underscores (when implemented everywhere).
The workaround for now is to do some additional definitions of underscore.
There is a function in gunittest which will do it for you [3]. You need to
explicitly call it before you execute the doctest which is exactly what the
dedicated test files in testsuites are doing, e.g. the one for script
package [4].
[1] https://trac.osgeo.org/grass/ticket/2425
[2] https://trac.osgeo.org/grass/changeset/67687
[3]
https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/gunittest/utils.py#L35
[4]
https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/script/testsuite/test_doctests.py
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20160218/7746d70d/attachment.html>
More information about the grass-dev
mailing list