[Twisted-Python] Twisted Trial

Gerrat Rickert grickert at coldstorage.com
Tue Jun 23 09:42:13 EDT 2009


I know this is a very basic question, but I can't seem to get trial
working correctly.
(I'm working on Windows XP, with python 2.5.4 and twisted 8.2.0)
I've created a very simple example:

I have a file, 'test_example.py'
It's contents are (between ======= lines):

==========================================
from twisted.trial import unittest

class ExampleTestCase(unittest.TestCase):

    def test_example(self):
        """A very simple test"""

        self.assertEquals(1,1)   


if __name__ == '__main__':
    import unittest
    unittest.main()
==========================================


if I just run:
'python text_example.py'
It runs the test (with python's regular unittest framework), and passes
ok

If I run:
'trial test_example.py'
It appears to run the test with trial, but gives this traceback:


Traceback (most recent call last):
  File "c:\python25\lib\site-packages\twisted\python\usage.py", line
241, in parseOptions
    self.postOptions()
  File "c:\python25\lib\site-packages\twisted\scripts\trial.py", line
293, in postOptions
    self['reporter'] = self._loadReporterByName(self['reporter'])
  File "c:\python25\lib\site-packages\twisted\scripts\trial.py", line
279, in _loadReporterByName
    for p in plugin.getPlugins(itrial.IReporter):
  File "c:\python25\lib\site-packages\twisted\plugin.py", line 200, in
getPlugins
    allDropins = getCache(package)
--- <exception caught here> ---
  File "c:\python25\lib\site-packages\twisted\plugin.py", line 165, in
getCache
    provider = pluginModule.load()
  File "c:\python25\lib\site-packages\twisted\python\modules.py", line
380, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "c:\python25\lib\site-packages\twisted\python\reflect.py", line
456, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "c:\python25\lib\site-packages\twisted\python\reflect.py", line
392, in _importAndCheckStack
    return __import__(importName)
  File "c:\python25\lib\site-packages\twisted\plugins\notestplugin.py",
line 18, in <module>
    assert not TEST.running
exceptions.AttributeError: 'module' object has no attribute 'running'
Traceback (most recent call last):
  File "c:\python25\lib\site-packages\twisted\python\usage.py", line
241, in parseOptions
    self.postOptions()
  File "c:\python25\lib\site-packages\twisted\scripts\trial.py", line
293, in postOptions
    self['reporter'] = self._loadReporterByName(self['reporter'])
  File "c:\python25\lib\site-packages\twisted\scripts\trial.py", line
279, in _loadReporterByName
    for p in plugin.getPlugins(itrial.IReporter):
  File "c:\python25\lib\site-packages\twisted\plugin.py", line 200, in
getPlugins
    allDropins = getCache(package)
--- <exception caught here> ---
  File "c:\python25\lib\site-packages\twisted\plugin.py", line 165, in
getCache
    provider = pluginModule.load()
  File "c:\python25\lib\site-packages\twisted\python\modules.py", line
380, in load
    return self.pathEntry.pythonPath.moduleLoader(self.name)
  File "c:\python25\lib\site-packages\twisted\python\reflect.py", line
456, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "c:\python25\lib\site-packages\twisted\plugins\testplugin.py",
line 12, in <module>
    from twisted.plugin import IPlugin, ITestPlugin, ITestPlugin2
exceptions.ImportError: cannot import name ITestPlugin
test_example
  ExampleTestCase
    test_example ...
[OK]

------------------------------------------------------------------------
-------
Ran 1 tests in 0.000s

PASSED (successes=1)

Could someone point out what I am doing wrong (or is this traceback
"Normal")? 
(I found some post on the web about a possible cause being invalid .pyc
files left over from a previous twisted install, so I deleted all .pyc
files under site-packages\twisted - but still get this traceback)

Thanks,
	Gerrat






More information about the Twisted-Python mailing list