New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Corrected iteritems py2/3 compatability in test_api.py #6886
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ fuzzywuzzy>=0.11 | |
pyelftools>=0.24 | ||
jsonschema>=2.6 | ||
future>=0.16.0 | ||
six>=1.11.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
Author: Przemyslaw Wirkus <Przemyslaw.wirkus@arm.com> | ||
""" | ||
from __future__ import print_function | ||
import six | ||
|
||
import os | ||
import re | ||
|
@@ -2126,12 +2127,12 @@ def predicate(base_pred, name_base_group_case): | |
|
||
# Apply common directories | ||
for pred, path in commons: | ||
for test_identity, test_paths in tests.iteritems(): | ||
for test_identity, test_paths in six.iteritems(tests): | ||
if pred(test_identity): | ||
test_paths.append(path) | ||
|
||
# Drop identity besides name | ||
return {name: paths for (name, _, _, _), paths in tests.iteritems()} | ||
return {name: paths for (name, _, _, _), paths in six.iteritems(tests)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using return {name: paths for (name, _, _, _), paths in tests.items()} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm... When I first came across the bug, I found something pointing to items() as performing much worse than six.iteritems(). Since I can't seen to find that document again, I'll make the change. |
||
|
||
def print_tests(tests, format="list", sort=True): | ||
"""Given a dictionary of tests (as returned from "find_tests"), print them | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
six
is not currently a required package from mbed-os, so we can't use this without adding it as a requirement.But see my other suggestion below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh. I was under the impression that six was already required due to #5022. It looks like requirements needs to be updated regardless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, yeah that's definitely using that. Its a very common package so maybe it just works most of the time? Well maybe it wouldn't hurt to add it as an explicit dependency in requirements.txt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that a different package ends up installing it as a dependency. I noticed it showed up after a fresh virtual environment.