[Twisted-Python] Using twisted.trial with nose unittest system
Has anyone tried/succeded at using twisted.trial with the nose unittest system? The twisted.trial system works well for pure twisted testing but I would like to get some of the advaned capabilities of nose in there as well. Any advice would be greatly appreciated. Thanks, Allen
On 2/7/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
Has anyone tried/succeded at using twisted.trial with the nose unittest system?
The twisted.trial system works well for pure twisted testing but I would like to get some of the advaned capabilities of nose in there as well. Any advice would be greatly appreciated.
Hey Allen, I haven't used (or even heard of) nose before. What features from nose do you want to use with Trial? As for getting them to work together, Trial tries very hard to be compatible with the standard library's unittest module, so if nose understands that, it ought to understand Trial tests.[1] cheers, jml [1] There are a couple of known instances where they won't work. Hopefully they are listed on the bug tracker.
On 2/6/07, Jonathan Lange <jml@mumak.net> wrote:
On 2/7/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
Has anyone tried/succeded at using twisted.trial with the nose unittest system?
The twisted.trial system works well for pure twisted testing but I would like to get some of the advaned capabilities of nose in there as well. Any advice would be greatly appreciated.
Hey Allen,
I haven't used (or even heard of) nose before. What features from nose do you want to use with Trial?
Nose seems like of like the standard python unittesting framework on steroids. It has a great deal of nice features. You can take a look here: http://somethingaboutorange.com/mrl/projects/nose/
As for getting them to work together, Trial tries very hard to be compatible with the standard library's unittest module, so if nose understands that, it ought to understand Trial tests.[1]
I spent some more time investigating this today and found that someone has written a plugin for nose that allows it to test twisted code. I don't think it looks as nice as trial, but it should work for the basics. You can see it here: http://python-nose.googlecode.com/svn/trunk/nose/twistedtools.py If I run into some serious issues I will try my best to extend this plugin to support additional capabilities from trial. Thanks, Allen
cheers, jml
[1] There are a couple of known instances where they won't work. Hopefully they are listed on the bug tracker.
On 2/6/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
someone has written a plugin for nose that allows it to test twisted code. I don't think it looks as nice as trial, but it should work for the basics. You can see it here: http://python-nose.googlecode.com/svn/trunk/nose/twistedtools.py
UGH def threaded_reactor(): -- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/
On 2/6/07, Christopher Armstrong <radix@twistedmatrix.com> wrote:
On 2/6/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
someone has written a plugin for nose that allows it to test twisted code. I don't think it looks as nice as trial, but it should work for the basics. You can see it here: http://python-nose.googlecode.com/svn/trunk/nose/twistedtools.py
UGH
def threaded_reactor():
Yep. Not pretty by any means. :( I am sure that any suggestions you have to make it better would be well-recieved by the nose project and the plugin's author. :) -Allen
-- Christopher Armstrong International Man of Twistery http://radix.twistedmatrix.com/ http://twistedmatrix.com/ http://canonical.com/
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On 2/7/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
On 2/6/07, Christopher Armstrong <radix@twistedmatrix.com> wrote:
On 2/6/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
someone has written a plugin for nose that allows it to test twisted code. I don't think it looks as nice as trial, but it should work for the basics. You can see it here: http://python-nose.googlecode.com/svn/trunk/nose/twistedtools.py
UGH
def threaded_reactor():
Yep. Not pretty by any means. :(
I am sure that any suggestions you have to make it better would be well-recieved by the nose project and the plugin's author. :)
I still need to spend some more time looking at nose, but in this particular case I think the plugin is unnecessary. If your tests subclass twisted.trial.unittest.TestCase, then they should take care of the reactor themselves.[1] cheers, jml [1] For the moment. There are plans to change this, but they are many, many months away from implementation.
On 2/6/07, Jonathan Lange <jml@mumak.net> wrote:
On 2/7/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
On 2/6/07, Christopher Armstrong <radix@twistedmatrix.com> wrote:
On 2/6/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
someone has written a plugin for nose that allows it to test twisted code. I don't think it looks as nice as trial, but it should work for the basics. You can see it here: http://python-nose.googlecode.com/svn/trunk/nose/twistedtools.py
UGH
def threaded_reactor():
Yep. Not pretty by any means. :(
I am sure that any suggestions you have to make it better would be well-recieved by the nose project and the plugin's author. :)
I still need to spend some more time looking at nose, but in this particular case I think the plugin is unnecessary.
If your tests subclass twisted.trial.unittest.TestCase, then they should take care of the reactor themselves.[1]
I tried this and things did not work out well. I am currently getting some exceptions inside nose that make me think twisted.trial may have modified the unittest state in a way that it didn't expect. It is always possible though that this is just a side effect of my testing method. Has anyone else tried using trial unittest's directly inside nose? -Allen
Ok, so I found a way to fix this. I now have nose running with a twisted-based test derived from twisted.trial.unittest.TestCase. I had to patch nose to get this to work: See: http://groups.google.com/group/nose-users/browse_frm/thread/0b8e6d7c165032ec Thanks for all the feedback. Hopefully things will just work now. :) -A On 2/9/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
On 2/6/07, Jonathan Lange <jml@mumak.net> wrote:
On 2/7/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
On 2/6/07, Christopher Armstrong <radix@twistedmatrix.com> wrote:
On 2/6/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
someone has written a plugin for nose that allows it to test twisted code. I don't think it looks as nice as trial, but it should work for the basics. You can see it here: http://python-nose.googlecode.com/svn/trunk/nose/twistedtools.py
UGH
def threaded_reactor():
Yep. Not pretty by any means. :(
I am sure that any suggestions you have to make it better would be well-recieved by the nose project and the plugin's author. :)
I still need to spend some more time looking at nose, but in this particular case I think the plugin is unnecessary.
If your tests subclass twisted.trial.unittest.TestCase, then they should take care of the reactor themselves.[1]
I tried this and things did not work out well. I am currently getting some exceptions inside nose that make me think twisted.trial may have modified the unittest state in a way that it didn't expect.
It is always possible though that this is just a side effect of my testing method. Has anyone else tried using trial unittest's directly inside nose?
-Allen
On Tue, 6 Feb 2007 18:05:36 -0600, Allen Bierbaum <abierbaum@gmail.com> wrote:
On 2/6/07, Christopher Armstrong <radix@twistedmatrix.com> wrote:
On 2/6/07, Allen Bierbaum <abierbaum@gmail.com> wrote:
someone has written a plugin for nose that allows it to test twisted code. I don't think it looks as nice as trial, but it should work for the basics. You can see it here: http://python-nose.googlecode.com/svn/trunk/nose/twistedtools.py
UGH
def threaded_reactor():
Yep. Not pretty by any means. :(
I am sure that any suggestions you have to make it better would be well-recieved by the nose project and the plugin's author. :)
You never mentioned why nose interested you. What's the attraction? Jean-Paul
[..]
Yep. Not pretty by any means. :(
I am sure that any suggestions you have to make it better would be well-recieved by the nose project and the plugin's author. :)
You never mentioned why nose interested you. What's the attraction?
I thought I added a link to the page, but you have to look down to the features sections to see the details: http://somethingaboutorange.com/mrl/projects/nose/ The most significant feature I like right now is the test discovery. It just works and makes sense since it will find classes, methods, modules, packages, nested packages, everything. It also allows setup and teardown methods at the module and package scope which can come in very handy to setup more expensive fixtures. The output capture seems like a good feature but I haven't had to use it much yet (it captures the stdout during a test and only shows it if there is a failure). The assertion messages are cleaner, it support plugins, the list goes on. The summary is that it is just more featureful then the standard unittest module and it seems like a more solid well-reasoned framework for testing. It doesn't do everything, but the things it does do make a lot of seem to make development easier. Reading through the link above doesn't take long and it does give a good idea of the capabilities. -Allen
participants (4)
-
Allen Bierbaum -
Christopher Armstrong -
Jean-Paul Calderone -
Jonathan Lange