[GRASS-dev] gunittest and unicode

Anna Petrášová kratochanna at gmail.com
Wed Mar 20 20:26:53 PDT 2019


On Fri, Mar 15, 2019 at 7:13 AM Stefan Blumentrath <
Stefan.Blumentrath at nina.no> wrote:

> Dear all,
>
>
>
> Recently, I have been looking into failing tests.
>
> A number of tests fail with “AssertionError: actual argument is not a
> string” [1]. These tests use “assertLooksLike”.
>
>
>
> The reason why the tests are failing is that stdout from “SimpleModule”
> deliveres unicode objects [2], while  “assertLooksLike” only allows/expects
> str objects [3].
>
>
>
> In many cases, encoding stdout wth utf-8 (or wrapping it into str() like
> in [2]) would fix this.
>
>
>
> If you consider this an appropriate solution I can fix tests accordingly…
>
>
>
> Alternatively, assertLooksLike could be changed to accept Unicode (too)…
>

Generally, the rule is to expect unicode and deal with that, so in this
case check for str or unicode (use e.g.
https://stackoverflow.com/a/11301392/1058453)

Anna

>
>
> Let me know. I do like to contribute to getting a “green build” (as Panos
> put it), but I want to double check what the most appropriate solution is
> before I make any changes…
>
> And in particular I do not want to mess with stuff others are currently
> working on…
>
>
>
> BTW, it the nc_spm_full_v2alpha test data available somewhere?
>
>
>
> Cheers
>
> Stefan
>
>
>
> 1:
> http://fatra.cnr.ncsu.edu/grassgistests/reports_for_date-2019-03-14-07-00/report_for_nc_spm_full_v2alpha_nc/vector/v.what/test_vwhat_ncspm/index.html
>
> 2:
> https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/gunittest/gmodules.py#L39
>
> 3:
> https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/gunittest/case.py#L179
>
>
>
>
>
> P.S.: The v.vect.stats test does not really test what it is supposed to
> test, which is why it does not fail although it also uses assertLooksLike:
> https://trac.osgeo.org/grass/browser/grass/trunk/vector/v.vect.stats/testsuite/test_vect_stats.py#L63
>
>
> _______________________________________________
> grass-dev mailing list
> grass-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20190320/e7bb2fa3/attachment.html>


More information about the grass-dev mailing list