Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > unittest problems

Reply
Thread Tools

unittest problems

 
 
Richard Wesley
Guest
Posts: n/a
 
      07-28-2003
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
 
Reply With Quote
 
 
 
 
John J. Lee
Guest
Posts: n/a
 
      07-29-2003
Richard Wesley <(E-Mail Removed)> 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%3DIS O-8859-1%26as_uauthors%3Djjl%40pobox.com%26lr%3D%26num%3D 30%26hl%3Den>

http://tinyurl.com/ig2q


John
 
Reply With Quote
 
 
 
 
Richard Wesley
Guest
Posts: n/a
 
      07-30-2003
In article <(E-Mail Removed)>, http://www.velocityreviews.com/forums/(E-Mail Removed) (John J. Lee)
wrote:

> Richard Wesley <(E-Mail Removed)> 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&l...k2o.fsf%40pobo
> x.com&rnum=1&prev=/groups%3Fas_q%3Dunittest%26safe%3Dimages%26ie%3DIS O-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_
 
Reply With Quote
 
John J. Lee
Guest
Posts: n/a
 
      07-30-2003
Richard Wesley <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unittest - adding a doctest suite to unittest.main Paul Moore Python 1 10-14-2008 03:32 PM
Unittest and dynamically created methods JAWS Python 2 10-15-2003 08:34 AM
Unittest and dynamically created methods JAWS Python 0 10-14-2003 07:42 PM
weird unittest result Gonšalo Rodrigues Python 3 10-01-2003 11:30 PM
How do you do unittest? Will Stuyvesant Python 5 08-02-2003 07:18 AM



Advertisments