[IronPython] False? with Unit Test

Michael Foord fuzzyman at voidspace.org.uk
Sat Apr 5 19:21:33 CEST 2008


Curt Hagenlocher wrote:
> It's the call to sys.exit that does this.
>
> There's a subtle difference between IronPython 2.0B1 and CPython 2.5 
> when sys.exit is called with a boolean parameter.  CPython doesn't 
> print the value of the parameter if it's boolean, while IronPython 
> does.  Presumably, CPython does this for backwards compatibility with 
> a time when it didn't have a boolean data type. I'd guess that 
> sys.exit(False) gets the same behavior as sys.exit(0) while 
> sys.exit(True) is the same as sys.exit(1).  But I haven't checked the 
> CPython source to confirm that guess.

As bool inherits from int, calling 'sys.exit' with False ought to be 
exactly the equivalent of calling it with 0. (False == 0, True == 1).

This obscure fact *is* because of backwards compatibility.

Michael
http://www.ironpythoninaction.com/

>
> On Sat, Apr 5, 2008 at 6:06 AM, Davy Mitchell <daftspaniel at gmail.com 
> <mailto:daftspaniel at gmail.com>> wrote:
>
>     Hello List,
>
>     Found a little funny on the latest IPY.
>
>         import unittest
>        
>         class ATest(unittest.TestCase):
>             def setUp(self):
>                 self.pop = ""
>             def test_blog(self):
>                 print "test"
>            
>         if __name__ == '__main__':
>             unittest.main()
>        
>     Runs fine but under IPY there's a extra line with 'False' output:
>
>     test
>     .
>     --------------------------------------------------------------
>     Ran one test in 0.096s
>
>     OK
>     False
>
>     Anyone had more experience with this module?
>
>     Davy
>
>     -- 
>     Davy Mitchell
>     Blog - http://www.latedecember.co.uk/sites/personal/davy/
>     Twitter - http://twitter.com/daftspaniel
>     Skype - daftspaniel http://needgod.com
>     _______________________________________________
>     Users mailing list
>     Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
>     http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   




More information about the Ironpython-users mailing list