unittest problems

R

Richard Wesley

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,
 
J

John J. Lee

Richard Wesley said:
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&...-1&[email protected]&lr=&num=30&hl=en>

http://tinyurl.com/ig2q


John
 
R

Richard Wesley

[email protected] (John J. Lee) said:
<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 _).
 
J

John J. Lee

Richard Wesley said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top