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

Unified Diff: tests/main_test.py

Issue 47623004: chromium-status: tests: handle -vv and -vvv flags (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/chromium-status
Patch Set: switch to optparse Created 7 years, 1 month 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/main_test.py
diff --git a/tests/main_test.py b/tests/main_test.py
index 8fe5462cb312e8750a78900c9351d8597df82434..af842a03a0169d16038db46857bb178433f8872b 100755
--- a/tests/main_test.py
+++ b/tests/main_test.py
@@ -6,6 +6,7 @@
import hashlib
import json
import logging
+import optparse
import os
import re
import sys
@@ -358,8 +359,16 @@ class AccessControl(TestCase):
self.assertEqual('True\n', result)
+def _init_logging(argv):
+ """Set up our logging by re-using some of the unittest flags"""
+ parser = optparse.OptionParser()
+ parser.add_option('-v', action='count', default=0)
+ (opts, _) = parser.parse_args([x for x in argv if x.startswith('-v')])
+
+ levels = [logging.WARNING, logging.INFO, logging.DEBUG]
+ logging.basicConfig(level=levels[min(2, opts.v)])
+
+
if __name__ == '__main__':
- logging.basicConfig(level=
- [logging.WARNING, logging.INFO, logging.DEBUG][
- min(2, sys.argv.count('-v'))])
+ _init_logging(sys.argv)
unittest.main()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698