Chromium Code Reviews| Index: tools/chrome_proxy/webdriver/common.py |
| diff --git a/tools/chrome_proxy/webdriver/common.py b/tools/chrome_proxy/webdriver/common.py |
| index 381ba75ba31df5567ad675d0f32feb9d31f1602b..2067a62e1f3aa283ea2710ea911d5af26e4e2d90 100644 |
| --- a/tools/chrome_proxy/webdriver/common.py |
| +++ b/tools/chrome_proxy/webdriver/common.py |
| @@ -527,15 +527,22 @@ class IntegrationTest(unittest.TestCase): |
| http_response.response_headers['via']) |
| @staticmethod |
| - def RunAllTests(): |
| + def RunAllTests(run_all_tests=False): |
| """A simple helper method to run all tests using unittest.main(). |
| + |
| + Args: |
| + run_all_tests: If True, all tests in the directory will be run, Otherwise |
| + only the tests in the file given on the command line will be run. |
| """ |
| flags = ParseFlags() |
| logger = GetLogger() |
| logger.debug('Command line args: %s', str(sys.argv)) |
| logger.info('sys.argv parsed to %s', str(flags)) |
| - # The unittest library uses sys.argv itself and is easily confused by our |
| - # command line options. Pass it a simpler argv instead, while working in the |
| - # unittest command line args functionality. |
| - unittest.main(argv=[sys.argv[0]], verbosity=2, failfast=flags.failfast, |
| - catchbreak=flags.catch, buffer=(not flags.disable_buffer)) |
| + if flags.catch: |
| + unittest.installHandler() |
| + pattern = '*.py' if run_all_tests else os.path.basename(sys.argv[0]) |
| + loader = unittest.TestLoader() |
| + tests = loader.discover('.', pattern=pattern) |
|
RyanSturm
2016/12/22 18:40:20
s/'.'/os.path.dirname(__file__)/ or something simi
Robert Ogden
2016/12/22 18:53:00
Done.
|
| + testRunner = unittest.runner.TextTestRunner(verbosity=2, |
| + failfast=flags.failfast, buffer=(not flags.disable_buffer)) |
| + testRunner.run(tests) |