From: <pj...@us...> - 2008-01-13 02:55:25
|
Revision: 4018 http://jython.svn.sourceforge.net/jython/?rev=4018&view=rev Author: pjenvey Date: 2008-01-12 18:55:24 -0800 (Sat, 12 Jan 2008) Log Message: ----------- add optparse. patch its test to not assume CPython dict ordering and __builtins__ Modified Paths: -------------- trunk/jython/CPythonLib.includes trunk/jython/Lib/test/regrtest.py trunk/jython/Lib/test/test_optparse.py Modified: trunk/jython/CPythonLib.includes =================================================================== --- trunk/jython/CPythonLib.includes 2008-01-13 02:53:48 UTC (rev 4017) +++ trunk/jython/CPythonLib.includes 2008-01-13 02:55:24 UTC (rev 4018) @@ -76,6 +76,7 @@ nntplib.py ntpath.py nturl2path.py +optparse.py pdb.py pickle.py pickletools.py Modified: trunk/jython/Lib/test/regrtest.py =================================================================== --- trunk/jython/Lib/test/regrtest.py 2008-01-13 02:53:48 UTC (rev 4017) +++ trunk/jython/Lib/test/regrtest.py 2008-01-13 02:55:24 UTC (rev 4018) @@ -983,7 +983,6 @@ test_nis test_normalization test_openpty - test_optparse test_ossaudiodev test_parser test_plistlib Modified: trunk/jython/Lib/test/test_optparse.py =================================================================== --- trunk/jython/Lib/test/test_optparse.py 2008-01-13 02:53:48 UTC (rev 4017) +++ trunk/jython/Lib/test/test_optparse.py 2008-01-13 02:55:24 UTC (rev 4018) @@ -8,6 +8,7 @@ # $Id: test_optparse.py 35634 2004-04-01 07:38:49Z fdrake $ # +import __builtin__ import sys import os import copy @@ -165,8 +166,14 @@ ["---"]) def test_attr_invalid(self): - self.assertOptionError("invalid keyword arguments: foo, bar", - ["-b"], {'foo': None, 'bar': None}) + try: + make_option(*["-b"], **{'foo': None, 'bar': None}) + except OptionError, oe: + msg = str(oe) + self.assertNotEqual(msg.find("invalid keyword arguments: "), -1) + self.assert_(msg.endswith('foo, bar') or msg.endswith('bar, foo')) + else: + self.fail('No OptionError raised.') def test_action_invalid(self): self.assertOptionError("invalid action: 'foo'", @@ -395,10 +402,16 @@ self.parser.add_option("--foz", action="store", type="string", dest="foo") possibilities = ", ".join({"--foz": None, "--foo": None}.keys()) - self.assertParseFail(["--f=bar"], - "ambiguous option: --f (%s?)" % possibilities) + try: + self.parser.parse_args(["--f=bar"]) + except SystemExit, se: + msg = str(se) + self.assertNotEqual(msg.find("ambiguous option: --f ("), -1) + self.assert_(msg.endswith('--foz, --foo?)') or \ + msg.endswith('--foo, --foz?)')) + else: + self.fail('No SystemExit raised.') - def test_short_and_long_option_split(self): self.assertParseOK(["-a", "xyz", "--foo", "bar"], {'a': 'xyz', 'boo': None, 'foo': ["bar"]}, @@ -461,14 +474,14 @@ (options, args) = self.assertParseOK(["-q"], {'verbose': 0}, []) - if hasattr(__builtins__, 'False'): + if hasattr(__builtin__, 'False'): self.failUnless(options.verbose is False) def test_bool_true(self): (options, args) = self.assertParseOK(["-v"], {'verbose': 1}, []) - if hasattr(__builtins__, 'True'): + if hasattr(__builtin__, 'True'): self.failUnless(options.verbose is True) def test_bool_flicker_on_and_off(self): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |