Python for large projects

gabor gabor at z10n.net
Wed Mar 24 12:50:21 EST 2004


On Wed, 2004-03-24 at 15:16, Bill Rubenstein wrote:
> ...snip... 
> > > other thing is, that in the projects i work on, there seems to be
> > > very hard to do unit tests
> ...snip...
> 
> The ability to do unit testing should not be an afterthought.  It should be 
> considered as a major influence on the architecture of a project.
> 
> If one cannot do proper unit testing, the architecture of the project is 
> questionable.

ok, so let's use a specific example:

imagine you're building a library, which fetches webpages. 

you have a library which can fetch 1 webpage at a time, but it is a
synchronous library (like wget). you call him, and he returns the page.

but you want an async one.

so you decide to build a threadpool, where every thread will do this:
look into a queue, and if there is a new URL to fetch, fetches it with
his wget-like library, and saves the html page somewhere (and maybe
signals something).

and now the user who uses your library, simply adds the URL to fetch,
and can check later asynchronously whether they are already fetched or
not.

could you tell me what unit tests would you create for this example?


(a more generic request: is there on the internet a webpage with
something like this? one where they have some complex
modules/programs/algorithms, and they show how to write unittests for
them?)

thanks,
gabor





More information about the Python-list mailing list