473,407 Members | 2,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

unittest problems

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
Jul 18 '05 #1
3 1455
Richard Wesley <ha******@trustedmedianetworks.com> 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
Jul 18 '05 #2
In article <87************@pobox.com>, jj*@pobox.com (John J. Lee)
wrote:
Richard Wesley <ha******@trustedmedianetworks.com> 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_
Jul 18 '05 #3
Richard Wesley <ha******@trustedmedianetworks.com> 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
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Will Stuyvesant | last post by:
I have a unittest testfile like this: ----------------------- test_mod.py --------------------- import sys sys.path.append('..') import unittest import mod class...
2
by: Raaijmakers, Vincent \(GE Infrastructure\) | last post by:
In my enthusiasm of separating my unittests from my business logic modules, I encounter some problems in my path setting. Can solve them, but so ugly. Needs suggestions in the right way to do it. ...
0
by: Remy Blank | last post by:
Ok, here we go. I added the possibility for tests using the unittest.py framework to be skipped. Basically, I added two methods to TestCase: TestCase.skip(msg): skips unconditionally...
1
by: Thomas Heller | last post by:
I'm trying to integrate some doctest tests with unittest. The tests must be exposed as one or more subclasses of unittest.TestCase, so I'm collecting them with a call to doctest.DocTestSuite(),...
41
by: Roy Smith | last post by:
I've used the standard unittest (pyunit) module on a few projects in the past and have always thought it basicly worked fine but was just a little too complicated for what it did. I'm starting a...
7
by: Jorgen Grahn | last post by:
I have a set of tests in different modules: test_foo.py, test_bar.py and so on. All of these use the simplest possible internal layout: a number of classes containing test*() methods, and the good...
3
by: David Vincent | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hello I'm hoping to get some insight into a situation that seems odd to me. My Python experience is limited; I've just started using the unittest module....
2
by: Oleg Paraschenko | last post by:
Hello, I decided to re-use functionality of "unittest" module for my purposes. More precisely, I have a list of folders. For each folder, code should enter to the folder, execute a command and...
0
by: Chris Fonnesbeck | last post by:
I have built the following unit test, observing the examples laid out in the python docs: class testMCMC(unittest.TestCase): def setUp(self): # Create an instance of the sampler...
1
by: Chris Fonnesbeck | last post by:
I have a module for which I am trying to code a unit test. However, when I run unittest.main(), I get: In : import PyMC In : PyMC.unittest.main() ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.