Community: Framework mailing list archives

expert-framework@mail.odoo.com

Re: assert_equals in yaml python blocks

by
Camptocamp France SAS, Alexandre Fayolle - Camptocamp
- 09/24/2014 02:24:09
On 23/09/2014 17:49, Leonardo "LeartS" Donelli wrote:
> That dependency is necessary only for running the tests though, and I
> don't think putting nose in __openerp__.py as a python dependency,
> when it isn't really required for the module to work, is a good
> practice. Or at least it should be highlighted.
>
> Can't you just use YAML !assert blocks and your 3 lines python
> equivalent of assert_equals when YAML !assert doesn't work? It's
> standard python and not that much longer.
>
> What I'm saying is: Between yaml !assert, yaml !python blocks, and
> unittests, I'm no sure the missing assert_equals is enough to justify
> adding a "fake" dependency to the module, required only to run tests.
>

Let's see things from another point of view.

Let's say I decide to write tests for my module which use nose (for
whatever reason).

1. if I don't declare nose as a dependency

* you can install and use the module the module without installing nose
* you cannot run the tests without installing nose, and you have to dig
in the stack trace to understand that

2. if I declare nose as a dependency

* Odoo will require that you install nose before you install the module
* you will be able to use the module and run the tests

The installation of nose in your dev environment costs almost nothing,
does you no harm, and can ease the work of developers, which can find it
easier to provide tests for their modules and to get meaningful error
messages[1] in their tests. In my book, easing the maintenance work
trumps easing deployment any time, especially when the deployment issue
is a matter of apt-get install python-nose. It is not as if this was
requiring you to setup an LDAP server which would only be used by tests.

Alternatively, we could ask Odoo SA to support a different key in
__openerp__.py to list development_dependencies, but this really sounds
overkill.


[1] the point of assert_equal(a, b) is mainly that: adapting the error
message when a != b to the types of a and b.

-- 
Alexandre Fayolle
Chef de Projet
Tel : + 33 (0)4 79 26 57 94

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac Cedex
http://www.camptocamp.com