Skip to content

Instantly share code, notes, and snippets.

@cneill
Created April 13, 2016 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cneill/2fe86d0b8e5931a2d9ae411114c06bfb to your computer and use it in GitHub Desktop.
Save cneill/2fe86d0b8e5931a2d9ae411114c06bfb to your computer and use it in GitHub Desktop.
def _logTests(self, tests, bucket, status=None):
"""Log each test by adding to self.all_tests and the right "bucket"
based on the status of the test (e.g. self.aggregated_errors)
:param list tests: test results (e.g. test.failures)
:param dict bucket: place to store the tests (e.g. self.aggregated_errors)
"""
for issue in tests:
url = issue.request.url
method = issue.request.method
parts = six.moves.urllib.parse.urlparse(url)
hostname = parts.netloc
path = parts.path
if hostname not in bucket:
bucket[hostname] = {}
if method not in bucket[hostname]:
bucket[hostname][method] = {}
method_tests = bucket[hostname][method]
if path not in method_tests:
method_tests[path] = {}
path_tests = method_tests[path]
issue_dict = issue.as_dict()
if status:
issue_dict["status"] = status
if issue.test not in path_tests:
path_tests[issue.test] = [issue_dict]
else:
path_tests[issue.test].append(issue_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment