unittest problems

Discussion in 'Python' started by Richard Wesley, Jul 28, 2003.

  1. Hi all -

    I am trying to retrofit some units test into our code using the unittest
    module. I can get individual rewrites to work, but I am having trouble
    writing the "one test to run them all and in the darkness bind them"
    script. There are two main sources of trouble:

    - Test data that is stored next to the script that uses it;
    - Several levels of scripts (top/utils/tests) with tests/data scattered
    at all levels;

    Are there any good examples out there of a more complex set of tests in
    a multilevel tree/package with attached test data? What about standard
    conventions for hooking stuff together (suite(), etc.)?

    TIA,

    --

    - rmgw

    <http://www.trustedmedianetworks.com/>

    ----------------------------------------------------------------------------
    Richard Wesley Trusted Media Networks, Inc.

    "Oh boy! Have you forgotten the plot again?"
    - Rocket J. Squirrel
     
    Richard Wesley, Jul 28, 2003
    #1
    1. Advertising

  2. Richard Wesley

    John J. Lee Guest

    Richard Wesley <> writes:

    > I am trying to retrofit some units test into our code using the unittest
    > module. I can get individual rewrites to work, but I am having trouble
    > writing the "one test to run them all and in the darkness bind them"
    > script. There are two main sources of trouble:
    >
    > - Test data that is stored next to the script that uses it;
    > - Several levels of scripts (top/utils/tests) with tests/data scattered
    > at all levels;
    >
    > Are there any good examples out there of a more complex set of tests in
    > a multilevel tree/package with attached test data? What about standard
    > conventions for hooking stuff together (suite(), etc.)?



    <http://www.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=873ci3lk2o.fsf%40pobox.com&rnum=1&prev=/groups%3Fas_q%3Dunittest%26safe%3Dimages%26ie%3DISO-8859-1%26as_uauthors%3Djjl%40pobox.com%26lr%3D%26num%3D30%26hl%3Den>

    http://tinyurl.com/ig2q


    John
     
    John J. Lee, Jul 29, 2003
    #2
    1. Advertising

  3. In article <>, (John J. Lee)
    wrote:

    > Richard Wesley <> writes:
    >
    > > I am trying to retrofit some units test into our code using the unittest
    > > module. I can get individual rewrites to work, but I am having trouble
    > > writing the "one test to run them all and in the darkness bind them"
    > > script. There are two main sources of trouble:
    > >
    > > - Test data that is stored next to the script that uses it;
    > > - Several levels of scripts (top/utils/tests) with tests/data scattered
    > > at all levels;
    > >
    > > Are there any good examples out there of a more complex set of tests in
    > > a multilevel tree/package with attached test data? What about standard
    > > conventions for hooking stuff together (suite(), etc.)?

    >
    >
    > <http://www.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=873ci3lk2o.fsf@pobo
    > x.com&rnum=1&prev=/groups%3Fas_q%3Dunittest%26safe%3Dimages%26ie%3DISO-8859-1%
    > 26as_uauthors%3Djjl%40pobox.com%26lr%3D%26num%3D30%26hl%3Den>
    >
    > http://tinyurl.com/ig2q


    Thanks.

    My problem turned out to be that the existing code had lots of relative
    import statements (from FileInSameDir import blah) which caused import
    to barf when called from a different level in the tree. Not to mention
    a few missing __init__.py files. Once I cleaned everything up, it all
    worked and the main unit_test.py will run everything. I used your
    code, driving it with the results of os.path.walk and parameterizing the
    pattern as a list (we have two test case file name patterns, one for
    intercaps and one for _).

    --

    - rmgw

    <http://www.trustedmedianetworks.com/>

    ----------------------------------------------------------------------------
    Richard Wesley Trusted Media Networks, Inc.

    "'And now', cried Max, 'let the wild rumpus start!'"
    - Maurice Sendak, _Where The Wild Things Are_
     
    Richard Wesley, Jul 30, 2003
    #3
  4. Richard Wesley

    John J. Lee Guest

    Richard Wesley <> writes:
    [...]
    > worked and the main unit_test.py will run everything. I used your
    > code, driving it with the results of os.path.walk and parameterizing the

    [...]

    *My* code? Well, fine, I suppose, but probably Bernhard Herzog's &
    somebody else's posts there had better code...


    John
     
    John J. Lee, Jul 30, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Will Stuyvesant

    How do you do unittest?

    Will Stuyvesant, Aug 1, 2003, in forum: Python
    Replies:
    5
    Views:
    368
    Will Stuyvesant
    Aug 2, 2003
  2. Gonçalo Rodrigues

    weird unittest result

    Gonçalo Rodrigues, Oct 1, 2003, in forum: Python
    Replies:
    3
    Views:
    315
    Gonçalo Rodrigues
    Oct 2, 2003
  3. JAWS
    Replies:
    2
    Views:
    299
    Duncan Booth
    Oct 15, 2003
  4. JAWS
    Replies:
    0
    Views:
    244
  5. Paul  Moore
    Replies:
    1
    Views:
    385
    Paul Moore
    Oct 14, 2008
Loading...

Share This Page