[FRPythoneers] Doctest

Jim Vickroy Jim.Vickroy at noaa.gov
Fri Jul 27 09:23:04 MDT 2001

> [snip]

> The best case that comes to me for not using the function semantics is if
> you want to run the test against a large list of data.  For example, I was
> writing some code which did a comparison between RPM version strings, and
> for testing I was considering generating a table based on the output of the
> C implementation so I could refactor it in Python.  I was going to generate
> a list of thousands of these strings and the expected results based on
> real-world version strings on a distributions.
> In PyUnit, if I were to do:
>    for lhs, rhs, expected in rpmVersTestList:
>       test.failIfNotEqual(rpmverscmp(lhs, rhs), expected)
> it's going to terminate at the first one found, and in fact there doesn't
> seem to be a real way to get them all to run short of doing something like
> the following in the test setup:
>    i = 0
>    for lhs, rhs, expected in rpmVersTestList:
>       setattr(self, 'test%04d',
>             lambda test, x = lhs, y = rhs, z = expected:
>             test.failIfNotEqual(x, y, z))
> In this case, the most important data I can get from the test-suite is not
> that one of the tests failed, but the pattern of WHICH tests failed.  That
> allows me to determine that, for example, all tests which had a release
> name of the format "number-string-number" were failing.  Or version strings
> that both have a trailing alpha string have the logic reversed.
> Evelyn asserts that this is regression testing, not unit testing, so maybe
> what I want to do just isn't suitable for the unittest module.

In your particular example, my approach has been to write a separate test case for
each pattern to be validated.  I have not encountered a case where the number of
patterns to be tested was prohibitive.

> Guess you don't need any more of Uche and I tag-teaming you...  I do agree
> with him that supporting people who test both ways would be nice though...
> Thanks for the pointers.
> Sean
> --
>  We are all in the gutter, but some of us are looking at the stars.
>                  -- Oscar Wilde
> Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
> tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe | FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers

More information about the FRPythoneers mailing list