[Twisted-Python] Re: [Twisted-commits] CVS: Twisted/twisted/test test_protocols.py,1.6,1.7

Glyph Lefkowitz glyph at twistedmatrix.com
Tue Sep 25 16:38:48 EDT 2001


On Tue, Sep 25, 2001 at 08:09:37PM +0200, Moshe Zadka wrote:
> On Tue, 25 Sep 2001, Itamar Shtull-Trauring <itamarst at twistedmatrix.com> wrote:
> 
> > +            assert r.brokenPeer, "connection wasn't closed on illegal netstring %s" % repr(s)
> 
> Itamar, and everybody: STOP DOING THAT!!!!!!!!!!!!!!!!!!!!!!!!
> Don't use "assert" in tests, since they don't operate under python -O.
> Someday, we'll want to test it working ok with -O. (say, if there is some
> less-then-trivial code undef "if __debug__".)

I don't think we should ever assume that Twisted will work under -O.  Does Zope?

Python's -O does change the semantics of the language and get rid of a cool
convenience syntax (albeit in a trivial manner) for an *extremely* marginal
performance boost.  Also, even if you test and test and test until you're SURE
it's perfect, and then you run your 'production code' without any testing
information available, that doesn't change the story when your 'production
code' does fail, as it inevitably will.

I am reminded of the quotefile entry:

"""
<lyn:#lisp> making things fast generally seems to involve trading space for time
<dan`b:#lisp> not so!  you're thinking like a typical lisp programer
<dan`b:#lisp> you can also trade correctness, like any self-respecting C hacker
"""

However in doing some reading before answering this message, I found out that
PyUnit has some nifty useful methods like "assertEquals" and "assertRaises"
that we should probably be using for tests anyway, so maybe the point is moot.
Those that are missing (like 'assertHasAttribute') we can probably write
ourselves.  :-)

-- 
______      you are in a maze of twisted little applications, all
|   |_\     remarkably consistent.
|     |          -- glyph lefkowitz, glyph @ twisted matrix . com
|_____|             http://www.twistedmatrix.com/





More information about the Twisted-Python mailing list