Add doctest for example in the library reference.
diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py
index 70ea65b..13834b8 100644
--- a/Lib/test/test_getopt.py
+++ b/Lib/test/test_getopt.py
@@ -125,6 +125,46 @@
 verify(opts == [('-a', '')])
 verify(args == ['arg1', '-b', '1', '--alpha', '--beta=2'])
 
+#------------------------------------------------------------------------------
+
+libreftest = """
+Examples from the Library Reference:  Doc/lib/libgetopt.tex
+
+An example using only Unix style options:
+
+
+>>> import getopt
+>>> args = '-a -b -cfoo -d bar a1 a2'.split()
+>>> args
+['-a', '-b', '-cfoo', '-d', 'bar', 'a1', 'a2']
+>>> optlist, args = getopt.getopt(args, 'abc:d:')
+>>> optlist
+[('-a', ''), ('-b', ''), ('-c', 'foo'), ('-d', 'bar')]
+>>> args
+['a1', 'a2']
+
+Using long option names is equally easy:
+
+
+>>> s = '--condition=foo --testing --output-file abc.def -x a1 a2'
+>>> args = s.split()
+>>> args
+['--condition=foo', '--testing', '--output-file', 'abc.def', '-x', 'a1', 'a2']
+>>> optlist, args = getopt.getopt(args, 'x', [
+...     'condition=', 'output-file=', 'testing'])
+>>> optlist
+[('--condition', 'foo'), ('--testing', ''), ('--output-file', 'abc.def'), ('-x', '')]
+>>> args
+['a1', 'a2']
+
+"""
+
+__test__ = {'libreftest' : libreftest}
+
+import doctest, sys
+doctest.testmod(sys.modules[__name__])
+
+#------------------------------------------------------------------------------
 
 if verbose:
     print "Module getopt: tests completed successfully."