Skip to content

Commit f91c896

Browse files
committed
Update tests to use argparse too.
1 parent 98f3896 commit f91c896

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

tests/test.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
import difflib
21-
import optparse
21+
import argparse
2222
import os.path
2323
import sys
2424
import subprocess
@@ -112,39 +112,41 @@ def main():
112112

113113
test_dir = os.path.dirname(os.path.abspath(__file__))
114114

115-
optparser = optparse.OptionParser(
116-
usage="\n\t%prog [options] [format] ...")
117-
optparser.add_option(
115+
argparser = argparse.ArgumentParser(
116+
usage="\n\t%(prog)s [options] [format] ...")
117+
argparser.add_argument(
118118
'-p', '--python', metavar='PATH',
119-
type="string", dest="python", default=sys.executable,
119+
dest="python", default=sys.executable,
120120
help="path to python executable [default: %default]")
121-
optparser.add_option(
121+
argparser.add_argument(
122122
'-g', '--gprof2dot', metavar='PATH',
123-
type="string", dest="gprof2dot", default=os.path.abspath(os.path.join(test_dir, os.path.pardir, 'gprof2dot.py')),
123+
dest="gprof2dot", default=os.path.abspath(os.path.join(test_dir, os.path.pardir, 'gprof2dot.py')),
124124
help="path to gprof2dot.py script [default: %default]")
125-
optparser.add_option(
125+
argparser.add_argument(
126126
'-f', '--force',
127127
action="store_true",
128128
dest="force", default=False,
129129
help="force reference generation")
130-
optparser.add_option(
130+
argparser.add_argument(
131131
'-c', '--coverage',
132132
action="store_true",
133133
dest="coverage", default=False,
134134
help="code coverage")
135135

136136
# Added this to avoid failing the test when a (hopefully small) number of formats
137137
# result in error. This allows some flexibility in CI testing.
138-
optparser.add_option(
138+
argparser.add_argument(
139139
'--max-acceptable',
140140
type=int,
141141
dest="max_acceptable",
142142
help="max acceptable errors before we return an errcode and fail the test")
143143

144-
(options, args) = optparser.parse_args(sys.argv[1:])
144+
options = argparser.add_argument('formats', nargs='*')
145145

146-
if len(args):
147-
formats = args
146+
options = argparser.parse_args(sys.argv[1:])
147+
148+
if len(options.formats):
149+
formats = options.formats
148150

149151
for format in formats:
150152
test_subdir = os.path.join(test_dir, format)

0 commit comments

Comments
 (0)