new error

29 views
Skip to first unread message

Cato Nano

unread,
Jan 21, 2018, 11:11:46 PM1/21/18
to tryton
In testing my module for the first time, this error is reported

----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 198, in wrapper
result = func(*args, **kwargs)
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 361, in test_field_methods
getattr(record, attr)()
File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/model/fields/field.py", line 106, in wrapper
return func(self, *args, **kwargs)
File "/home/catonano/tributi/build/lib/trytond/modules/tributi/affissione.py", line 38, in on_change_with_fattoreGiorni
ng = abs((self.on_change_with_bollettaDataFine() - self.on_change_with_bollettaDataInizio()).days)
TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'

----------------------------------------------------------------------


but when I run it in the GUI, fattoreGiorni DOES WORK

I swear !

You can see a picture here
https://imgur.com/a/kUUjs

Sergi Almacellas Abellana

unread,
Jan 22, 2018, 3:32:40 AM1/22/18
to try...@googlegroups.com
El 22/01/18 a les 05:11, Cato Nano ha escrit:
> In testing my module for the first time, this error is reported
>
> ----------------------------------------------------------------------
> Traceback (most recent call last):
> File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 198, in wrapper
> result = func(*args, **kwargs)
> File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/tests/test_tryton.py", line 361, in test_field_methods
> getattr(record, attr)()
> File "/home/catonano/tributi/env/lib/python3.6/site-packages/trytond/model/fields/field.py", line 106, in wrapper
> return func(self, *args, **kwargs)
> File "/home/catonano/tributi/build/lib/trytond/modules/tributi/affissione.py", line 38, in on_change_with_fattoreGiorni
> ng = abs((self.on_change_with_bollettaDataFine() - self.on_change_with_bollettaDataInizio()).days)
> TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType'
>
> ----------------------------------------------------------------------

The problem is that both on_change functions return a None value and
python does not know how too substract None from None. That's because
the test suite call all on_change functions with an empty object to
ensure that they correctly work when there is no value on the form.

You should take in account None values on your function.
>
>
> but when I run it in the GUI, fattoreGiorni DOES WORK
>
> I swear !
>
> You can see a picture here
> https://imgur.com/a/kUUjs
>


--
Sergi Almacellas Abellana
www.koolpi.com
Twitter: @pokoli_srk

Cato Nano

unread,
Jan 22, 2018, 1:03:15 PM1/22/18
to tryton
Thank you Sergi

I managed to give my date fiuelds default values AND make my methods return a date _anyway_.

That allowed the tests to pass
Reply all
Reply to author
Forward
0 new messages