[TIP] Guidelines for where to put tests & how to package them

Olemis Lang olemis at gmail.com
Thu Feb 25 08:48:38 PST 2010


On Thu, Feb 25, 2010 at 11:22 AM, C. Titus Brown <ctb at msu.edu> wrote:
> On Thu, Feb 25, 2010 at 09:56:30AM -0500, Olemis Lang wrote:
>> On Thu, Feb 25, 2010 at 12:01 AM, C. Titus Brown <ctb at msu.edu> wrote:
>>
[...]
>> > Comments?
>>
>> It's great for the start, but I prefer `python setup.py test -m
>> somepackage.test.run` (not sure about `test.run` yet ...) for testing
>> everything in there, because it's more explicit, promotes a well known
>> set of command line arguments and relieson distutils commands (and you
>> can see by just looking at the command line ;o), so the command can
>> perform a build or take whatever action it needs in order to satisfy
>> the preconditions needed to run tests (e.g. installing ). Sometimes
>> it's also useful to test just a well-known subset of what's been done
>> (e.g. GViz QL Python client library that's implemented inside TracGviz
>> plugin ;o) . In that case using -s or similar is useful.
>
> Hmm, I'm just going to have to call "WTF" on you here:
>

No problem ;o)

>  python setup.py test -m somepackage.test ...
>
> This has several problems, now that I've retroactively defined my
> conditions -- see my response to Robert.  The problems:
>
>  - requires distutils extension for 'test' command

Nope, that could be specified or overriden in `setup.py` using
`cmdclass` keyword arg, so anything is possible. However if the
problem is the command name `test` we could call it somehow different.
What about `test_default` | `test_xxx` ?
;o)

>  - is potentially redundant or at least contains unnecessary information
>   ('test, plus, run this')

I don't get it, `python setup.py test -m somepackage.tests` means «Use
python to run setup.py script, where I have specified -otherwise use
default ;o)- the distutils command to use in order to run the tests,
and extract everything at somepackage.tests» . So it's very explicit .

Besides the short version could be `python setup.py test ` if
`test_suite` or `test_module` is specified explicitly in the test
script ;o)

The benefit I see in this case is that it's always possible to do
(without modifying the script ;o) something like

{{{
#!sh

$ python setup.py test_junitxml -m somepackage.test
$ python setup.py test_junitxml
$ python setup.py test_anything
}}}

and therefore config is (should be) more flexible. How would you do
that using `python -m somepackage.test.run` ?

>  - confuses arguments to the setup.py test command with arguments to
>   python (what does '-m' go with -- python, or setup.py, or test?)
>

test, but if you want more explicit invokation then

{{{
#!sh

$ python setup.py test --test-module=somepackage.tests
}}}

;o)

> So -1 on this from me!
>

so, still -1 ? ...

>> > Complaints?
>>
>> How could anybody complain ?
>
> ...obviously you haven't attended PyCon lately.
>

nevermind /me joking

:P

-- 
Regards,

Olemis.

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Re: [Python-Dev] setUpClass and setUpModule in unittest :: ASPN ...  -
http://feedproxy.google.com/~r/TracGViz-full/~3/y2L-XX7-3vQ/3817074



More information about the testing-in-python mailing list