[Twisted-Python] Get trial to use the docstring?

Nathan nathan.stocks at gmail.com
Thu Aug 5 19:25:35 EDT 2010


On Thu, Aug 5, 2010 at 1:49 PM,  <exarkun at twistedmatrix.com> wrote:
>>If you want to add a feature that prints out the docstring (or some
>>portion of it) _in addition_ to the test name, that would probably be
>>accepted as a patch.  But, in my mind, one of the most important
>>features of trial is the fact that it prints out stable identifiers for
>>the tests so you can see how to run them again when you're looking at
>>their results.  We should never omit that.  (In fact, I'd really like
>>it if trial always printed out a _full_ test identifier for easy
>>copy/pasting instead of sometimes only printing the method name.)
>
> Also, trial reporters are pluggable, so you can always write and use a
> reporter that prints out exactly what you want printed out.
>
> Jean-Paul

I have a number of questions:

1) I found the TreeReporter class that produces the default output
(twisted/trial/reporter.py), and I found the file that seems to get
run by trial (twisted/scripts/trial.py) but for the life of me I
couldn't figure out how to get my own class to show up as one of the
reporters that you can select by means of the --reporter=whatever
argument.  How do you tie the two together?  I can just submit my
modified TreeReporter, but it'd be nice to be able to also submit a
wildly different option...

2) What's the official process for submitting a patch (or where is the
process documented)?  I've never actually contributed code to
twisted...

3) Every time I install my custom twisted (with "sudo python setup.py
install" on OS X 10.6.4 system python), trial starts spitting out the
"dropin cache" error (see [1] below) which persists until I run "sudo
twistd --help" as was suggested on the list last week or so.  Isn't
there some way we can just address that error condition at
installation time so that doesn't occur in the first place?

4) I'm sold on test-driven development (which is why I'm learning
trial), so I'd like to both check for regressions and write a test for
my patch.  I found twisted/trial/test/test_reporter.py -- how do I run
just the tests in that file?  Does trial run on itself?

~ Nathan


[1] Traceback (most recent call last):
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0_r29921-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_r29921-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_r29921-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_r29921-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_r29921-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_r29921-py2.6-macosx-10.6-universal.egg/twisted/python/filepath.py",
line 765, in setContent
    f = sib.open('w')
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0_r29921-py2.6-macosx-10.6-universal.egg/twisted/python/filepath.py",
line 515, in open
    return self.create()
  File "/Library/Python/2.6/site-packages/Twisted-10.1.0_r29921-py2.6-macosx-10.6-universal.egg/twisted/python/filepath.py",
line 791, 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_r29921-py2.6-macosx-10.6-universal.egg/twisted/plugins/bDcpsOvnXomi7b94dropin.cache.new'



More information about the Twisted-Python mailing list