> The link you provided gives an example of using the unittest classes
> (not doctest), in which you can import anything you want since it is
> just a python file.

AlterEgo 213 (which Jon linked to) does not show how to get your
controllers to see your database models- the example code doesn't
interact with a database at all. I've tried every snippet of promising
code on the mailing list and haven't been successful. I, too, would
appreciate an example of exposing models to a controller in an
external unit test

<A rather lengthy aside to counter the large pile of "just use
doctests" posts in the group archives>
The biggest downside to doctests is that they do a poor job of testing
functions that rely heavily on a database. Since doctests don't
automatically run setUp() and tearDown() functions before/after every
test (as external unit tests do) you have to devise clunky,
inconvenient ways to bring the database back to a known state for each
test.

Another downside to doctests is they are harder to organize; you can't
cleanly separate different sorts of tests that all relate to the same
function (i.e., when a function is very sensitive to initial
conditions). With external unit tests each logically distinct test can
be represented with a distinct function, and that test can be run on
it's own, without the overhead of any other tests (unlike doctests,
where everything that tests a function must be run in order to test
the part you're interested in).
</aside>

As the AlterEgo example shows, web2py already supports external unit
testing. All that's missing is an example demonstrating how to test a
database-driven function.

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to