Re: Re: rewrote tests in unittest/ to python unittests

Bram Moolenaar <[email protected]>
Newsgroups gmane.comp.tools.aap.devel
Message-ID <[email protected]>
Joerg Beyer wrote:

> please verify that my version works for you. yes, I took all tests that
> were in the unittest directory (and hopefully did not miss any :-)

It appears to work for me.  It looks like you included all the existing
tests.  However, much more needs still needs to be tested.  It should be
easy to add now.

> > One thing I noticed is that you "import *" from Process.  That is not a
> 
> well, this is what your unittest/process.py did, but you are right,
> "from XXX import *" is in generall not a good idea.

You can blame me for this then.

> > > I included the unittest.py (since Bram works with older
> > > python releases that have it not includes - todays 
> > > python releases have). It originally lives on:
> > > pyunit.sourceforge.net
> > 
> > I'm using Python 2.2, which does include the module.  Since the module
> 
> oh, has changed recently? 

In the changelog, under "What's New in Python 2.1 beta 2?":

- unittest.py, a unit testing framework by Steve Purcell (PyUNIT,
  inspired by JUnit), is now part of the standard library.  You now
  have a choice of two testing frameworks: unittest requires you to
  write testcases as separate code, doctest gathers them from
  docstrings.  Both approaches have their advantages and
  disadvantages.

> > We can produce a warning when the module is not available, with a hint
> > where to obtain the module.  I suppose it's simple to install.  I'll add
> yes, since the unittest.py is self contained you can unpack the pyunit
> tarball and simply copy/move their unittest.py in a-a-p's unittest
> directory (you could even provide a receipe to do that, right?)

Hmm, making an installable package recipe for this wouldn't be a bad
idea.  If someone makes this I'll add it to the web site.  You can find
examples here: http://www.a-a-p.org/packages/

> > > Later I will append unittest, that actually run receipes to test, if they
> > > work. This tarball tests on a lower layer: python functions and classes,
> > > but the technique is the same.
> > 
> > In what way would that be different from what is currently used to
> > execute the tests in the "rectest" directory?
> 
> I thought that that was, what you initially wanted. To clarify this:
> unittest are best in testing (smaller) units. 
> 
> The running of the tests in rectest is an integration test, that takes
> the entire aap and you dont really need the unittest interface to
> do this.

As you can see in test.aap this testing already works.  It's a bit slow,
because Aap has to be restarted every time.  I don't think this can be
avoided, this way of testing also checks that all required "import"
statements are present, for example.

> If you name a class that could be tested easliy (because it's
> interaction with other object is small) then I will try to figure
> out a unittest for it. Later, with a deeper understanding
> of aap's internals it might be easier for me to write some
> larger tests.

Most of the functions in Util.py and RecPython.py can be tested
individually.  Functions in other modules might also be tested
separately, but the more complex ones are probably better done by
executing a recipe.

> One thing that _should_ be unittest'ed is the aap-rule engine,
> but right now, I dont understand it good enough. One could
> provide a ruleset and trigger certain targets, expecting (or better:
> asserting) the right action to be triggered.

This isn't simple, but should be possible.  It involves creating a Work
object, adding items to it and then calling dictlist_update().

-- 
It was recently discovered that research causes cancer in rats.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///


-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.