Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: tools/chrome_proxy/webdriver/common.py

Issue 2598053002: Create run_all_tests script. (Closed)
Patch Set: Something cleaner Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/chrome_proxy/webdriver/run_all_tests.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..695bb5634bdbcbd619bdf44e642eded0ee9cb2f4 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(os.path.dirname(__file__), pattern=pattern)
+ testRunner = unittest.runner.TextTestRunner(verbosity=2,
+ failfast=flags.failfast, buffer=(not flags.disable_buffer))
+ testRunner.run(tests)
« no previous file with comments | « no previous file | tools/chrome_proxy/webdriver/run_all_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698