Hello,
I was working on lava-dispatcher today, and I found out that is has (few) unit tests under lava_dispatchers/tests/, and I was wondering if is there a pattern/guideline/etc on how unit tests are used acrosss the lava components. In special:
1) How are we supposed to run the unit tests? I found a .testr.conf file in lava-dispatcher, what gave me some hints, so I started doing
$ python -m subunit.run lava_dispatcher.tests.test_suite
The output of that was too verbose for my taste, so I ended up using
$ python -m unittest lava_dispatcher.tests.test_suite
which provides a cleaner output.
2) I had problems running these tests within the system (a VM) where I had lava installed, after activating the virtualenv-like environment with `. /src/lava/instances/$inst/bin/activate`. The commands above were always running the code that was installed in the lava instance instead of the code in the current directory. I guess that is related to the fact that I did not inject that directory to be used by the instance, right?
This made me end up running the tests on my main system, where there was nothing installed - only the lava-dispatcher sources + the basic Python stuff.
Antonio Terceiro antonio.terceiro@linaro.org writes:
Hello,
I was working on lava-dispatcher today, and I found out that is has (few) unit tests under lava_dispatchers/tests/, and I was wondering if is there a pattern/guideline/etc on how unit tests are used acrosss the lava components.
No :(
We are embarrassingly terrible at unit testing our code. If you starting can kick us into being a bit better, that would be awesome!
In special:
- How are we supposed to run the unit tests? I found a .testr.conf file
in lava-dispatcher, what gave me some hints, so I started doing
$ python -m subunit.run lava_dispatcher.tests.test_suite
The output of that was too verbose for my taste, so I ended up using
$ python -m unittest lava_dispatcher.tests.test_suite
which provides a cleaner output.
The presence of .testr.conf means that you can run tests by running "testr init" (once) and then "testr run" (after installing the testrepository package).
- I had problems running these tests within the system (a VM) where I
had lava installed, after activating the virtualenv-like environment with `. /src/lava/instances/$inst/bin/activate`. The commands above were always running the code that was installed in the lava instance instead of the code in the current directory. I guess that is related to the fact that I did not inject that directory to be used by the instance, right?
That's because after activating an instance, 'python' runs an interpreter with a fixed sys.path (I'm not sure that even $PYTHONPATH is honoured). This is both a good and bad thing... probably bad in this case.
This made me end up running the tests on my main system, where there was nothing installed - only the lava-dispatcher sources + the basic Python stuff.
As I think I said on IRC, I don't tend to do lava-dispatcher development inside an instance -- it doesn't depend on any of the other bits.
Cheers, mwh
W dniu 12.09.2012 02:34, Michael Hudson-Doyle pisze:
Antonio Terceiro antonio.terceiro@linaro.org writes:
Hello,
I was working on lava-dispatcher today, and I found out that is has (few) unit tests under lava_dispatchers/tests/, and I was wondering if is there a pattern/guideline/etc on how unit tests are used acrosss the lava components.
No :(
We are embarrassingly terrible at unit testing our code. If you starting can kick us into being a bit better, that would be awesome!
_some_ dispatcher originated code got additional tests in mantle (nee lava-core), mwhudson and andy can describe that later. Truth being told most of generic code _can_ be tested but dispatcher is rather difficult to work with for testing.
In special:
- How are we supposed to run the unit tests? I found a .testr.conf file
in lava-dispatcher, what gave me some hints, so I started doing
$ python -m subunit.run lava_dispatcher.tests.test_suite
The output of that was too verbose for my taste, so I ended up using
$ python -m unittest lava_dispatcher.tests.test_suite
which provides a cleaner output.
The presence of .testr.conf means that you can run tests by running "testr init" (once) and then "testr run" (after installing the testrepository package).
testr was used on lava-dispatcher and abrek (lava-test). Still you should be able to run setup.py test in all of our packages universally.
Thanks ZK
Zygmunt Krynicki zygmunt.krynicki@linaro.org writes:
testr was used on lava-dispatcher and abrek (lava-test). Still you should be able to run setup.py test in all of our packages universally.
Not the django ones :/ I did find some code once to make setup.py test run the django tests, but it burnt holes in my eyeballs.
Cheers, mwh
linaro-validation@lists.linaro.org