From: Frank C. <fc...@pu...> - 2004-09-28 20:35:49
|
Thanks Clark and Neil. re.match( "20", "200" ) not equal to None re.match( "20", "200" ) and 1 Both seem reminiscent of Bash scripting to me, and that's why I don't like Bash scripting. :-) It seems to me the better way would be to have a convenience method like: re.match("20", "200").toBoolean() What do you think about my patching the re library to do so? -Frank On Sep 28, 2004, at 6:07 AM, Updike, Clark wrote: > I think you want: > > TestCase.assert( "Problem", re.match( "20", "200" ) and 1 or 0) > > -Clark > > -----Original Message----- > From: On Behalf Of Frank Cohen > Sent: Tuesday, September 28, 2004 2:58 AM > Subject: [Jython-users] Jython, re, jUnit > > > I'm trying to use jUnit, re, and Jython in a test script. Here's how I > would like to see the script: > > from junit.framework import TestCase > import re > TestCase.assert( "Problem", re.match( "20", "200" ) ) > > The problem with this code is the re.match function returns None or > org.python.modules.sre.MatchObject. This causes TestCase.assert to > throw a "2nd arg can't be coerced to boolean" exception. > > I must be missing something simple but it's late and I'm seeking your > help. > > -Frank > > > --- > Frank Cohen, PushToTest, http://www.PushToTest.com, phone: 408 374 7426 > Author of "Java Testing and Design: From Unit Tests to Automated Web > Tests" > from Prentice Hall, details at http://thebook.pushtotest.com > > --- Frank Cohen, PushToTest, http://www.PushToTest.com, phone: 408 374 7426 Author of "Java Testing and Design: From Unit Tests to Automated Web Tests" from Prentice Hall, details at http://thebook.pushtotest.com |