[omniORB] Weird interaction between omniORBpy 2.0 and PyUnit 1.4.1
cp@sophos.com
cp@sophos.com
Wed Mar 26 13:55:03 2003
I have encountered an annoying problem when using omniORBpy 2.0 and PyUnit
1.4.1 with Python 2.2. If I use the unittestgui to execute the tests I can
only run the test once. The first run of my test suite goes ok, but the
second run displays the following error:
C:\home\corba\myfirst_python>test SimpleTests.SimpleTestSuite
Traceback (most recent call last):
File "c:\program
files\python22\lib\site-packages\pyunit-1.4.1\unittestgui.py"
, line 75, in runClicked
test = unittest.defaultTestLoader.loadTestsFromName(testName)
File "C:\PROGRA~1\PYTHON22\lib\site-packages\pyunit-1.4.1\unittest.py",
line 4
33, in loadTestsFromName
obj = getattr(obj, part)
AttributeError: 'module' object has no attribute 'SimpleTestSuite'
Now, the strange thing is that if I write my tests suite as follows,
everthing works fine:
---8<--- SimpleTests.py (no omniORBpy) ---8<---
import unittest
class SimpleTestCase(unittest.TestCase):
def runTest(self):
pass
def SimpleTestSuite():
suite = unittest.TestSuite()
suite.addTest(SimpleTestCase())
return suite
if __name__ == '__main__':
runner = unittest.TextTestRunner()
runner.run(SimpleTestSuite())
---8<------8<------8<------8<------8<------8<------
In other words I can press the "start" button on the PyUnit GUI to my
hearts content and everything works as expected. However, if I add just
the merest hint of omniORBpy into the mix then things start going wrong.
The simplest thing I have managed to come up with to demonstrate this is
by adding a single import as follows:
---8<--- SimpleTests.py (with a dash of omniORBpy) ---8<---
import unittest
from omniORB import CORBA
class SimpleTestCase(unittest.TestCase):
def runTest(self):
pass
def SimpleTestSuite():
suite = unittest.TestSuite()
suite.addTest(SimpleTestCase())
return suite
if __name__ == '__main__':
runner = unittest.TextTestRunner()
runner.run(SimpleTestSuite())
---8<------8<------8<------8<------8<------8<------
With this code I can only press the start button once. Subsequent presses
yield the error.
I have had a squint at the omniORBpy code and it appears to do some fancy
module shuffling in the omniORB.__init__ module which may give us a clue
to what's going on.
I have posted this message with both omniORB and PyUnit as I fear this may
be a weird interaction that may need work on both sides to resolve. Let me
know if I can help any further.
Cliff
--
Cliff Penton, Head of Software Architecture & Research, Sophos Anti-Virus
Email: cp@sophos.com, DDI: 01235 544017, Web: www.sophos.com
Add live virus info to your website: http://www.sophos.com/link/vfeed