| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import argparse | 5 import argparse |
| 6 import json | 6 import json |
| 7 import logging | 7 import logging |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import socket | 10 import socket |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 Args: | 520 Args: |
| 521 http_response: The HTTPResponse object to check. | 521 http_response: The HTTPResponse object to check. |
| 522 """ | 522 """ |
| 523 expected_via_header = ParseFlags().via_header_value | 523 expected_via_header = ParseFlags().via_header_value |
| 524 self.assertNotIn('via', http_response.response_headers) | 524 self.assertNotIn('via', http_response.response_headers) |
| 525 if 'via' in http_response.response_headers: | 525 if 'via' in http_response.response_headers: |
| 526 self.assertNotIn(expected_via_header, | 526 self.assertNotIn(expected_via_header, |
| 527 http_response.response_headers['via']) | 527 http_response.response_headers['via']) |
| 528 | 528 |
| 529 @staticmethod | 529 @staticmethod |
| 530 def RunAllTests(): | 530 def RunAllTests(run_all_tests=False): |
| 531 """A simple helper method to run all tests using unittest.main(). | 531 """A simple helper method to run all tests using unittest.main(). |
| 532 |
| 533 Args: |
| 534 run_all_tests: If True, all tests in the directory will be run, Otherwise |
| 535 only the tests in the file given on the command line will be run. |
| 532 """ | 536 """ |
| 533 flags = ParseFlags() | 537 flags = ParseFlags() |
| 534 logger = GetLogger() | 538 logger = GetLogger() |
| 535 logger.debug('Command line args: %s', str(sys.argv)) | 539 logger.debug('Command line args: %s', str(sys.argv)) |
| 536 logger.info('sys.argv parsed to %s', str(flags)) | 540 logger.info('sys.argv parsed to %s', str(flags)) |
| 537 # The unittest library uses sys.argv itself and is easily confused by our | 541 if flags.catch: |
| 538 # command line options. Pass it a simpler argv instead, while working in the | 542 unittest.installHandler() |
| 539 # unittest command line args functionality. | 543 pattern = '*.py' if run_all_tests else os.path.basename(sys.argv[0]) |
| 540 unittest.main(argv=[sys.argv[0]], verbosity=2, failfast=flags.failfast, | 544 loader = unittest.TestLoader() |
| 541 catchbreak=flags.catch, buffer=(not flags.disable_buffer)) | 545 tests = loader.discover(os.path.dirname(__file__), pattern=pattern) |
| 546 testRunner = unittest.runner.TextTestRunner(verbosity=2, |
| 547 failfast=flags.failfast, buffer=(not flags.disable_buffer)) |
| 548 testRunner.run(tests) |
| OLD | NEW |