Re: [python-tulip] Writing unit tests for user code

2014-07-26 Thread Guido van Rossum
There's another thing. If you accidentally put a yield in a test_*() method, and you are using the default test runner, it will silently succeed without doing anything (since calling it just creates the generator object without starting the code). That's annoying. I personally think that this

Re: [python-tulip] Writing unit tests for user code

2014-07-25 Thread Tobias Oberstein
In Twisted, there is Trial, which provides an extended version of unittest.TestCase with this feature: The main unique feature of this testing class is the ability to return a ​Deferred from a test-case method. A test method which returns a snip I strongly recommend you reconsider doing

Re: [python-tulip] Writing unit tests for user code

2014-07-25 Thread Christopher Armstrong
On July 25, 2014 at 9:08:46 AM, Tobias Oberstein (tobias.oberst...@gmail.com) wrote: In Twisted, there is Trial, which provides an extended version of  unittest.TestCase with this feature:      The main unique feature of this testing class is the ability to return a  ​Deferred from a

Re: [python-tulip] Writing unit tests for user code

2014-07-25 Thread Tobias Oberstein
And: I'm sure Twisted developer's will have reasons for frowning upon tests returning deferreds, but could you recap shortly why? It has the classic problem with bad tests: reliance on global state which is not controlled by the test. Unit tests should be isolated, they should not affect or

Re: [python-tulip] Writing unit tests for user code

2014-07-25 Thread Luca Sbardella
I strongly recommend you reconsider doing this. The Twisted core developers have, for several years now, mostly eschewed the usage of returning Deferreds from test cases. Instead, tests are written by explicitly controlling all events explicitly, with careful use of test doubles to replace

Re: [python-tulip] Writing unit tests for user code

2014-07-22 Thread Ben Darnell
On Tue, Jul 22, 2014 at 6:00 PM, Tobias Oberstein tobias.oberst...@gmail.com wrote: So I guess what I am after is six for asyncio/Twisted ;) Isn't six for asyncio/Twisted covered by the fact that you can implement one event loop in terms of another? Idiomatic asyncio code and idiomatic

Re: [python-tulip] Writing unit tests for user code

2014-07-22 Thread Tobias Oberstein
So I guess what I am after is six for asyncio/Twisted ;) Isn't six for asyncio/Twisted covered by the fact that you can implement one event loop in terms of another? Idiomatic asyncio code Yep, wrapping a network library for some protocol written for network framework X for users to run