From 9755f3f302da86dc1f42a87fa32b08d975c55daa Mon Sep 17 00:00:00 2001 From: "Gordon P. Hemsley" Date: Sun, 28 Aug 2016 18:52:31 -0400 Subject: [PATCH] Switch tools/test-tools from optparse to argparse. --- tools/test-tools | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/test-tools b/tools/test-tools index 4ab0b9a211..a2b334ea16 100755 --- a/tools/test-tools +++ b/tools/test-tools @@ -3,17 +3,17 @@ from __future__ import absolute_import from __future__ import print_function -import optparse +import argparse import os import sys import unittest if __name__ == '__main__': - parser = optparse.OptionParser() - parser.add_option('--coverage', dest='coverage', + parser = argparse.ArgumentParser() + parser.add_argument('--coverage', dest='coverage', action="store_true", - default=False, help='Compute test coverage.') - (options, _) = parser.parse_args() + default=False, help='compute test coverage') + args = parser.parse_args() def dir_join(dir1, dir2): # type: (str, str) -> str @@ -27,7 +27,7 @@ if __name__ == '__main__': loader = unittest.TestLoader() # type: ignore # https://github.com/python/typeshed/issues/372 - if options.coverage: + if args.coverage: import coverage cov = coverage.Coverage(branch=True, omit=[ "*/zulip-venv-cache/*", dir_join(tools_test_dir, "*") ]) cov.start() @@ -38,7 +38,7 @@ if __name__ == '__main__': if result.errors or result.failures: raise Exception('Test failed!') - if options.coverage: + if args.coverage: cov.stop() cov.save() cov.html_report(directory='var/tools_coverage')