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)…
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
On Fri, Mar 15, 2019 at 7:13 AM Stefan Blumentrath <Stefan.Blumentrath@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@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev