[TIP] some general unittest questions

Andres Riancho andres.riancho at gmail.com
Tue Jul 23 06:23:52 PDT 2013


On Tue, Jul 23, 2013 at 9:36 AM, Rita <rmorgan466 at gmail.com> wrote:
> Hi,
>
> I have couple of questions regarding unittest module.
>
> Currently, I have test/module_test.py and I have my unit test there. Is it
> better to have multiple files or just one file (module_test.py) and have all
> my tests there?

Usually the directory used is "tests/", and the naming is "test_module.py".

You should have one file for each module, if you see that the
test_module.py file grows very large, maybe it's time to refactor the
original module because it's doing too many things; which will lead to
test_module_a.py and test_module_b.py

> I am currently running it via discovery mode, python -m
> unittest discover in my $ROOT location and things work very well!

Use nosetests instead

> Another question, is there a tool which will document my tests and generate
> a nice HTML page to describe the tests?

There should be a nosetests plugin for writing nice reports

>
>
> --
> --- Get your facts first, then you can distort them as you please.--
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>



--
Andrés Riancho
Project Leader at w3af - http://w3af.org/
Web Application Attack and Audit Framework
Twitter: @w3af
GPG: 0x93C344F3



More information about the testing-in-python mailing list