[Twisted-Python] trial newbie

Nathan nathan.stocks at gmail.com
Wed Jul 21 18:30:40 MDT 2010


Okay, so I'm just starting to learn how to use trial (I know, I'm a
bad, bad boy), and I'm having trouble getting started.

The trial page[1] says "Tests that subclass the standard library
TestCase and don't do anything "too weird" should be able to be
discoverable and runnable by the Trial test runner without the authors
of those tests having to jump through hoops."

So I made a small concept file to try that out:

=-=-=-=-=-=-=-
#!/usr/bin/env python

import unittest, sys
from distutils import version

class TestPrerequsites(unittest.TestCase):
   def setUp(self):
      pass

   def test_00(self):
      "Supported OS?"
      self.assertTrue(sys.platform in ['darwin'])

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


I named it 'test.py' and made sure it worked with python:


=-=-=-=-=-=-=-
$ python test.py -v
Supported OS? ... ok

----------------------------------------------------------------------
Ran 1 test in 0.000s

OK
=-=-=-=-=-=-=-


and then I tried running it in trial under Twisted 8.2.0 on OS
10.6...and it crashed...sorta.  A traceback was output, but after the
traceback stuff it also seemed to run the test.  So I thought, "I
probably just need to upgrade."  So I upgraded to Twisted 10.1.0 and
ran it again.  It still crashed...sorta.  Here's what it looks like.

$ trial test.py
Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/python/usage.py",
line 241, in parseOptions
    self.postOptions()
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/scripts/trial.py",
line 295, in postOptions
    self['reporter'] = self._loadReporterByName(self['reporter'])
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/scripts/trial.py",
line 281, in _loadReporterByName
    for p in plugin.getPlugins(itrial.IReporter):
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/plugin.py",
line 199, in getPlugins
    allDropins = getCache(package)
--- <exception caught here> ---
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/plugin.py",
line 178, in getCache
    dropinPath.setContent(pickle.dumps(dropinDotCache))
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/python/filepath.py",
line 745, in setContent
    f = sib.open('w')
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/python/filepath.py",
line 495, in open
    return self.create()
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/python/filepath.py",
line 771, in create
    fdint = os.open(self.path, _CREATE_FLAGS)
exceptions.OSError: [Errno 13] Permission denied:
'/Library/Python/2.6/site-packages/Twisted-10.1.0-py2.6-macosx-10.6-universal.egg/twisted/plugins/n8ARdewBqzybvuUpdropin.cache.new'
test
  TestPrerequsites
    test_00 ...                                                            [OK]

-------------------------------------------------------------------------------
Ran 1 tests in 0.023s

PASSED (successes=1)


Anyone know what's going on?  I installed/upgraded version 10.1.0 by
downloading the tarball and running "sudo python setup.py install"

~ Nathan

[1] http://twistedmatrix.com/documents/current/api/twisted.trial.html




More information about the Twisted-Python mailing list