[Twisted-Python] Twisted Trial

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

(snip) On 01:42 pm, grickert@coldstorage.com wrote:
Your problem is that you've installed two versions of Twisted using setup.py install, without removing Twisted in between. This means you have an old plugin lying around which is trying to import some things that no longer exist in "twisted.plugin". The traceback is mostly harmless, but you should really re-install Twisted from scratch so that you don't experience other issues related to this, such as spurious test failures. In general I would not recommend using 'setup.py' to install to site- packages directly, because of problems like this; you should use a tool like Combinator[1] or virtualenv[2] to manage your development dependencies. 1: http://www.divmod.org/trac/wiki/DivmodCombinator 2: http://pypi.python.org/pypi/virtualenv

(snip) On 01:42 pm, grickert@coldstorage.com wrote:
Your problem is that you've installed two versions of Twisted using setup.py install, without removing Twisted in between. This means you have an old plugin lying around which is trying to import some things that no longer exist in "twisted.plugin". The traceback is mostly harmless, but you should really re-install Twisted from scratch so that you don't experience other issues related to this, such as spurious test failures. In general I would not recommend using 'setup.py' to install to site- packages directly, because of problems like this; you should use a tool like Combinator[1] or virtualenv[2] to manage your development dependencies. 1: http://www.divmod.org/trac/wiki/DivmodCombinator 2: http://pypi.python.org/pypi/virtualenv
participants (2)
-
Gerrat Rickert
-
glyph@divmod.com