[Python-checkins] r78577 - in python/branches/py3k: Doc/library/allos.rst Doc/library/argparse.rst Doc/library/getopt.rst Doc/library/optparse.rst Doc/tutorial/stdlib.rst Lib/argparse.py Lib/test/test_argparse.py Misc/NEWS

steven.bethard python-checkins at python.org
Tue Mar 2 10:22:57 CET 2010


Author: steven.bethard
Date: Tue Mar  2 10:22:57 2010
New Revision: 78577

Log:
Merged revisions 78576 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r78576 | steven.bethard | 2010-03-02 00:38:09 -0800 (Tue, 02 Mar 2010) | 3 lines
  
  Initial commit of the argparse library, based on argparse 1.1.
  Docs still need some updating to make getopt and optparse match the wording promised in the PEP.
  There are also probably a number of :class:ArgumentParser etc. links that could be added to the argparse documentation.
........


Added:
   python/branches/py3k/Doc/library/argparse.rst
      - copied unchanged from r78576, /python/trunk/Doc/library/argparse.rst
   python/branches/py3k/Lib/argparse.py
      - copied unchanged from r78576, /python/trunk/Lib/argparse.py
   python/branches/py3k/Lib/test/test_argparse.py
      - copied, changed from r78576, /python/trunk/Lib/test/test_argparse.py
Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Doc/library/allos.rst
   python/branches/py3k/Doc/library/getopt.rst
   python/branches/py3k/Doc/library/optparse.rst
   python/branches/py3k/Doc/tutorial/stdlib.rst
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Doc/library/allos.rst
==============================================================================
--- python/branches/py3k/Doc/library/allos.rst	(original)
+++ python/branches/py3k/Doc/library/allos.rst	Tue Mar  2 10:22:57 2010
@@ -15,6 +15,7 @@
    os.rst
    io.rst
    time.rst
+   argparse.rst
    optparse.rst
    getopt.rst
    logging.rst

Modified: python/branches/py3k/Doc/library/getopt.rst
==============================================================================
--- python/branches/py3k/Doc/library/getopt.rst	(original)
+++ python/branches/py3k/Doc/library/getopt.rst	Tue Mar  2 10:22:57 2010
@@ -1,5 +1,5 @@
-:mod:`getopt` --- Parser for command line options
-=================================================
+:mod:`getopt` --- C-style parser for command line options
+=========================================================
 
 .. module:: getopt
    :synopsis: Portable parser for command line options; support both short and

Modified: python/branches/py3k/Doc/library/optparse.rst
==============================================================================
--- python/branches/py3k/Doc/library/optparse.rst	(original)
+++ python/branches/py3k/Doc/library/optparse.rst	Tue Mar  2 10:22:57 2010
@@ -1,8 +1,8 @@
-:mod:`optparse` --- More powerful command line option parser
-============================================================
+:mod:`optparse` --- Parser for command line options
+===================================================
 
 .. module:: optparse
-   :synopsis: More convenient, flexible, and powerful command-line parsing library.
+   :synopsis: Command-line option parsing library.
 .. moduleauthor:: Greg Ward <gward at python.net>
 .. sectionauthor:: Greg Ward <gward at python.net>
 

Modified: python/branches/py3k/Doc/tutorial/stdlib.rst
==============================================================================
--- python/branches/py3k/Doc/tutorial/stdlib.rst	(original)
+++ python/branches/py3k/Doc/tutorial/stdlib.rst	Tue Mar  2 10:22:57 2010
@@ -72,7 +72,7 @@
 
 The :mod:`getopt` module processes *sys.argv* using the conventions of the Unix
 :func:`getopt` function.  More powerful and flexible command line processing is
-provided by the :mod:`optparse` module.
+provided by the :mod:`argparse` module.
 
 
 .. _tut-stderr:

Copied: python/branches/py3k/Lib/test/test_argparse.py (from r78576, /python/trunk/Lib/test/test_argparse.py)
==============================================================================
--- /python/trunk/Lib/test/test_argparse.py	(original)
+++ python/branches/py3k/Lib/test/test_argparse.py	Tue Mar  2 10:22:57 2010
@@ -1450,7 +1450,7 @@
         Sig('-x', type=argparse.FileType()),
         Sig('spam', type=argparse.FileType('r')),
     ]
-    failures = ['-x', '-x bar']
+    failures = ['-x', '']
     successes = [
         ('foo', NS(x=None, spam=RFile('foo'))),
         ('-x foo bar', NS(x=RFile('foo'), spam=RFile('bar'))),
@@ -1473,7 +1473,7 @@
         Sig('-x', type=argparse.FileType('rb')),
         Sig('spam', type=argparse.FileType('rb')),
     ]
-    failures = ['-x', '-x bar']
+    failures = ['-x', '']
     successes = [
         ('foo', NS(x=None, spam=RFile('foo'))),
         ('-x foo bar', NS(x=RFile('foo'), spam=RFile('bar'))),
@@ -1506,7 +1506,7 @@
         Sig('-x', type=argparse.FileType('w')),
         Sig('spam', type=argparse.FileType('w')),
     ]
-    failures = ['-x', '-x bar']
+    failures = ['-x', '']
     successes = [
         ('foo', NS(x=None, spam=WFile('foo'))),
         ('-x foo bar', NS(x=WFile('foo'), spam=WFile('bar'))),
@@ -1521,7 +1521,7 @@
         Sig('-x', type=argparse.FileType('wb')),
         Sig('spam', type=argparse.FileType('wb')),
     ]
-    failures = ['-x', '-x bar']
+    failures = ['-x', '']
     successes = [
         ('foo', NS(x=None, spam=WFile('foo'))),
         ('-x foo bar', NS(x=WFile('foo'), spam=WFile('bar'))),
@@ -1894,7 +1894,7 @@
         parser.add_argument('baz')
         expected = NS(foo='1', bar='2', baz='3')
         result = parser.parse_args('1 2 3'.split())
-        self.failUnlessEqual(expected, result)
+        self.assertEqual(expected, result)
 
     def test_group_first(self):
         parser = ErrorRaisingArgumentParser()
@@ -1904,7 +1904,7 @@
         parser.add_argument('baz')
         expected = NS(foo='1', bar='2', baz='3')
         result = parser.parse_args('1 2 3'.split())
-        self.failUnlessEqual(expected, result)
+        self.assertEqual(expected, result)
 
     def test_interleaved_groups(self):
         parser = ErrorRaisingArgumentParser()
@@ -1916,7 +1916,7 @@
         group.add_argument('frell')
         expected = NS(foo='1', bar='2', baz='3', frell='4')
         result = parser.parse_args('1 2 3 4'.split())
-        self.failUnlessEqual(expected, result)
+        self.assertEqual(expected, result)
 
 # ===================
 # Parent parser tests
@@ -3783,7 +3783,7 @@
             e = sys.exc_info()[1]
             expected = 'unknown action'
             msg = 'expected %r, found %r' % (expected, e)
-            self.failUnless(expected in str(e), msg)
+            self.assertTrue(expected in str(e), msg)
 
     def test_multiple_dest(self):
         parser = argparse.ArgumentParser()
@@ -3794,7 +3794,7 @@
             e = sys.exc_info()[1]
             expected = 'dest supplied twice for positional argument'
             msg = 'expected %r, found %r' % (expected, e)
-            self.failUnless(expected in str(e), msg)
+            self.assertTrue(expected in str(e), msg)
 
     def test_no_argument_actions(self):
         for action in ['store_const', 'store_true', 'store_false',
@@ -4111,10 +4111,10 @@
         self.assertNotEqual(ns1, ns4)
         self.assertNotEqual(ns2, ns3)
         self.assertNotEqual(ns2, ns4)
-        self.failUnless(ns1 != ns3)
-        self.failUnless(ns1 != ns4)
-        self.failUnless(ns2 != ns3)
-        self.failUnless(ns2 != ns4)
+        self.assertTrue(ns1 != ns3)
+        self.assertTrue(ns1 != ns4)
+        self.assertTrue(ns2 != ns3)
+        self.assertTrue(ns2 != ns4)
 
 
 # ===================
@@ -4143,7 +4143,7 @@
     def test_argument_error(self):
         msg = "my error here"
         error = argparse.ArgumentError(None, msg)
-        self.failUnlessEqual(str(error), msg)
+        self.assertEqual(str(error), msg)
 
 # =======================
 # ArgumentTypeError tests
@@ -4163,7 +4163,7 @@
         except ArgumentParserError:
             expected = 'usage: PROG x\nPROG: error: argument x: spam!\n'
             msg = sys.exc_info()[1].stderr
-            self.failUnlessEqual(expected, msg)
+            self.assertEqual(expected, msg)
         else:
             self.fail()
 
@@ -4177,8 +4177,8 @@
         parser = argparse.ArgumentParser()
         parser.add_argument('--foo')
         args, extras = parser.parse_known_args('--foo F --bar --baz'.split())
-        self.failUnlessEqual(NS(foo='F'), args)
-        self.failUnlessEqual(['--bar', '--baz'], extras)
+        self.assertEqual(NS(foo='F'), args)
+        self.assertEqual(['--bar', '--baz'], extras)
 
     def test_mixed(self):
         parser = argparse.ArgumentParser()
@@ -4188,8 +4188,8 @@
 
         argv = ["B", "C", "--foo", "-v", "3", "4"]
         args, extras = parser.parse_known_args(argv)
-        self.failUnlessEqual(NS(v=3, spam=True, badger="B"), args)
-        self.failUnlessEqual(["C", "--foo", "4"], extras)
+        self.assertEqual(NS(v=3, spam=True, badger="B"), args)
+        self.assertEqual(["C", "--foo", "4"], extras)
 
 # ============================
 # from argparse import * tests
@@ -4199,7 +4199,7 @@
 
     def test(self):
         for name in argparse.__all__:
-            self.failUnless(hasattr(argparse, name))
+            self.assertTrue(hasattr(argparse, name))
 
 
 if __name__ == '__main__':

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Tue Mar  2 10:22:57 2010
@@ -722,6 +722,8 @@
 
 - Issue #6729: Added ctypes.c_ssize_t to represent ssize_t.
 
+- Issue #6247: The argparse module has been added to the standard library.
+
 Extension Modules
 -----------------
 


More information about the Python-checkins mailing list