[TIP] Context Sensitive Traceback in nosetests Error

Kamal Ahmed kamal2222ahmed at yahoo.com
Mon Jul 11 08:00:50 PDT 2011

I would appreciate of you can give me some pointers regarding the following issue.

I am running nosetests with command line option like --psql --mysql --qa, and other options.

when the tests fail, i get something like:

ERROR: testTSyncRes2 (transactionstest.TransactionsTest)
Traceback (most recent call last):
File "/home/k/hg/Pr-test/pr-test/decorators.py", line 34, in wrapper
return func(self)
File "/home/k/hg/Pr-test/pr-test/fixtures.py", line 105, in wrapper
File "/home/k/hg/Pr-test/pr-test/servertest/transactionstest.py", line 668, in testTSyncRes2 self.tSyncRes2()
File "/home/k/hg/Pr-test/pr-test/servertest/transactionstest.py", line 697, in tSyncRes2 remoteConfig, False) 
File "/home/k/hg/Pr/pr/server/classes/common/community.py", line 680, in tSyncRes1
 raise errors.SyncError('Remote server error: ' + str(e))
 SyncError: Remote server error: [Errno 13] Permission denied '/tmp/synclocktestTSyncRes2/session'

Now looking at the stack trace, i dont know if it was caused when using
--mysql or --psql command line option. since the same test runs for these options.

1. Is there a nosetests plugin that can append the command line context to Traceback ?
2. Is the best way to resolve this is to write a plugin ?if i were to write a plugin, i need a bit of help where to start. Like :

- Should i parse the command line options in a list and with Stack print out the list that was being used ? not sure how i would go about doing that.
I looked at :
1. /http://docs.python.org/library/traceback.html?#traceback.print_stack
2. Maybe add addError(test, err, context) without changing nose source.
3. get env.get('--mysql','--psql','--qa')

 def options(self, parser, env):
        """Sets additional command line options."""
        Plugin.options(self, parser, env)
            '--xunit-file', action='store',
            dest='xunit_file', metavar="FILE",
            default=env.get('NOSE_XUNIT_FILE', 'nosetests.xml'),
            help=("Path to xml file to store the xunit report in. "

          "Default is nosetests.xml in the working directory "
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20110711/8f96965d/attachment.html>

More information about the testing-in-python mailing list