<div dir="ltr"><div>Hi,<br><br></div>when writing tests which involve PyGRASS Module class I found that at some occasions the error messages are quite confusing. <br><div><div><br></div><div>First when you try to run one module twice, you get AttributeError:</div>

<div><br>>>> from grass.pygrass.modules import Module<br>>>> from subprocess import PIPE<br>>>> m = Module('<a href="http://r.info" target="_blank">r.info</a>', map='elevation', run_=False, stdout_=PIPE)<br>


>>> m.run()<br>>>> m.outputs['stdout'].value<br>...<br>>>> # running for the second time<br>>>> m.run()<br>Traceback (most recent call last)<br>    ...<br>AttributeError: 'str' object has no attribute 'fileno'<br>


<br></div><div>Second, when you confuse m.inputs['map'].value with m.inputs['map'] (which is pretty easy error to do) you get "TypeError: deletions are implemented differently for unicode":</div>

<div><br>>>> # this is OK<br>>>> m.inputs['map'].value = 5<br>Traceback (most recent call last)<br>    ...<br>TypeError: The Parameter <map>, require: raster, get: <type 'int'> instead<br>

>>> # this is not OK<br>>>> # confusing parameter object and parameter value<br>>>> m.inputs['map'] = 'aspect'<br>Traceback (most recent call last)<br>    ...<br>TypeError: deletions are implemented differently for unicode<br>

<br></div><div>With the former it depends what is actually allowed. Than it is probably easy to fix. With the later, no easy solutions come to my mind.<br><br></div><div>With my tests I was actually asserting m.outputs['stdout'] for true which is always true instead of asserting m.inputs['stdout'].value. I don't know how to avoid this mistake in general.<br>

</div><div><br></div><div>Does this make sense to you or do you think that I and PyGRASS users should be just be more careful?<br></div><div><br></div><div>Vaclav<br>
</div></div></div>