summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_optparse.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2004-04-01 07:40:35 (GMT)
committerFred Drake <fdrake@acm.org>2004-04-01 07:40:35 (GMT)
commit456d3258d64f4c60a7787dd59f5c68bafb81584c (patch)
tree1fb12da152101e04ddb1504c3845d3744783c096 /Lib/test/test_optparse.py
parent8effa01931b1917ddad7462ba4d1d4223357fe3a (diff)
downloadcpython-456d3258d64f4c60a7787dd59f5c68bafb81584c.zip
cpython-456d3258d64f4c60a7787dd59f5c68bafb81584c.tar.gz
cpython-456d3258d64f4c60a7787dd59f5c68bafb81584c.tar.bz2
Fix support for the "prog" keyword to the OptionParser constructor, as well
as directly setting the .prog attribute (which should be supported based on the class docstring). Closes SF bug #850964.
Diffstat (limited to 'Lib/test/test_optparse.py')
-rw-r--r--Lib/test/test_optparse.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index 4712446..37e229c 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -612,6 +612,22 @@ class TestVersion(BaseTest):
self.assertStdoutEquals(["--version"], "bar 0.1\n")
sys.argv[0] = oldargv
+ def test_version_with_prog_keyword(self):
+ oldargv = sys.argv[0]
+ sys.argv[0] = "./foo/bar"
+ self.parser = OptionParser(usage=SUPPRESS_USAGE, version="%prog 0.1",
+ prog="splat")
+ self.assertStdoutEquals(["--version"], "splat 0.1\n")
+ sys.argv[0] = oldargv
+
+ def test_version_with_prog_attribute(self):
+ oldargv = sys.argv[0]
+ sys.argv[0] = "./foo/bar"
+ self.parser = OptionParser(usage=SUPPRESS_USAGE, version="%prog 0.1")
+ self.parser.prog = "splat"
+ self.assertStdoutEquals(["--version"], "splat 0.1\n")
+ sys.argv[0] = oldargv
+
def test_no_version(self):
self.parser = OptionParser(usage=SUPPRESS_USAGE)
self.assertParseFail(["--version"],