Re: [Zope-dev] SVN: zope.tal/trunk/src/zope/tal/dummyengine.py assert isn't a function, using parens will cause the two arguments to be treated as a 2-tuple, hence always true.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Matthew Wilkes wrote: Log message for revision 93717: assert isn't a function, using parens will cause the two arguments to be treated as a 2-tuple, hence always true. Changed: U zope.tal/trunk/src/zope/tal/dummyengine.py -=- Modified: zope.tal/trunk/src/zope/tal/dummyengine.py === --- zope.tal/trunk/src/zope/tal/dummyengine.py2008-12-06 12:09:53 UTC (rev 93716) +++ zope.tal/trunk/src/zope/tal/dummyengine.py2008-12-06 13:25:25 UTC (rev 93717) @@ -85,8 +85,8 @@ return value def evaluate(self, expression): -assert (expression.startswith($) and expression.endswith($), -expression) +assert expression.startswith($) and expression.endswith($), \ +expression expression = expression[1:-1] m = name_match(expression) if m: @@ -152,8 +152,8 @@ return self.evaluate(expr) def evaluateMacro(self, macroName): -assert (macroName.startswith($) and macroName.endswith($), -macroName) +assert macroName.startswith($) and macroName.endswith($), \ +macroName macroName = macroName[1:-1] file, localName = self.findMacroFile(macroName) if not file: A better fix would be to strip outthe 'assert' keyword everywhere, and use 'self.failUnless' / 'self.failIf' instead: that would allow getting rid of the backsplash, as well. Tres. - -- === Tres Seaver +1 540-429-0999 [EMAIL PROTECTED] Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJPVjG+gerLs4ltQ4RAjZKAKDSJ2alTo+X6JjUypulCCB1cryn3QCfUktE Unhlfp28gYNPB3pyyHl+iM4= =n6K5 -END PGP SIGNATURE- ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] SVN: zope.tal/trunk/src/zope/tal/dummyengine.py assert isn't a function, using parens will cause the two arguments to be treated as a 2-tuple, hence always true.
On Mon, Dec 8, 2008 at 12:26 PM, Tres Seaver [EMAIL PROTECTED] wrote: A better fix would be to strip outthe 'assert' keyword everywhere, and use 'self.failUnless' / 'self.failIf' instead: that would allow getting rid of the backsplash, as well. Yep. Another reason not to use assert in tests is that if the tests are run with Python's -O or -OO switches, the asserts will be optimized away. -- Benji York Senior Software Engineer Zope Corporation ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] SVN: zope.tal/trunk/src/zope/tal/dummyengine.py assert isn't a function, using parens will cause the two arguments to be treated as a 2-tuple, hence always true.
Tres Seaver wrote: Matthew Wilkes wrote: Log message for revision 93717: assert isn't a function, using parens will cause the two arguments to be treated as a 2-tuple, hence always true. Changed: U zope.tal/trunk/src/zope/tal/dummyengine.py -=- Modified: zope.tal/trunk/src/zope/tal/dummyengine.py === --- zope.tal/trunk/src/zope/tal/dummyengine.py 2008-12-06 12:09:53 UTC (rev 93716) +++ zope.tal/trunk/src/zope/tal/dummyengine.py 2008-12-06 13:25:25 UTC (rev 93717) @@ -85,8 +85,8 @@ return value def evaluate(self, expression): -assert (expression.startswith($) and expression.endswith($), -expression) +assert expression.startswith($) and expression.endswith($), \ +expression expression = expression[1:-1] m = name_match(expression) if m: @@ -152,8 +152,8 @@ return self.evaluate(expr) def evaluateMacro(self, macroName): -assert (macroName.startswith($) and macroName.endswith($), -macroName) +assert macroName.startswith($) and macroName.endswith($), \ +macroName macroName = macroName[1:-1] file, localName = self.findMacroFile(macroName) if not file: A better fix would be to strip outthe 'assert' keyword everywhere, and use 'self.failUnless' / 'self.failIf' instead: that would allow getting rid of the backsplash, as well. Unless I'm missing something self.failUnless only works inside tests. This is in normal code, where I found assert statements just annoying for the most part. Hanno ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] SVN: zope.tal/trunk/src/zope/tal/dummyengine.py assert isn't a function, using parens will cause the two arguments to be treated as a 2-tuple, hence always true.
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hanno Schlichting wrote: Tres Seaver wrote: Matthew Wilkes wrote: Log message for revision 93717: assert isn't a function, using parens will cause the two arguments to be treated as a 2-tuple, hence always true. Changed: U zope.tal/trunk/src/zope/tal/dummyengine.py -=- Modified: zope.tal/trunk/src/zope/tal/dummyengine.py === --- zope.tal/trunk/src/zope/tal/dummyengine.py 2008-12-06 12:09:53 UTC (rev 93716) +++ zope.tal/trunk/src/zope/tal/dummyengine.py 2008-12-06 13:25:25 UTC (rev 93717) @@ -85,8 +85,8 @@ return value def evaluate(self, expression): -assert (expression.startswith($) and expression.endswith($), -expression) +assert expression.startswith($) and expression.endswith($), \ +expression expression = expression[1:-1] m = name_match(expression) if m: @@ -152,8 +152,8 @@ return self.evaluate(expr) def evaluateMacro(self, macroName): -assert (macroName.startswith($) and macroName.endswith($), -macroName) +assert macroName.startswith($) and macroName.endswith($), \ +macroName macroName = macroName[1:-1] file, localName = self.findMacroFile(macroName) if not file: A better fix would be to strip outthe 'assert' keyword everywhere, and use 'self.failUnless' / 'self.failIf' instead: that would allow getting rid of the backsplash, as well. Unless I'm missing something self.failUnless only works inside tests. This is in normal code, where I found assert statements just annoying for the most part. D'oh, you are correct! +1 to removing the asserts alogether. Tres. - -- === Tres Seaver +1 540-429-0999 [EMAIL PROTECTED] Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFJPXIM+gerLs4ltQ4RAlVbAJ9qwQrta7+16o4+i3b1Nl8goewEtACfU0DC vOzkFTvsbGYHObJfiz3ALuI= =bY08 -END PGP SIGNATURE- ___ Zope-Dev maillist - Zope-Dev@zope.org http://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope )