-
Notifications
You must be signed in to change notification settings - Fork 1
Tests/update tests for ckan 2.11 python 3 #117
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
Tests/update tests for ckan 2.11 python 3 #117
Conversation
For each language in the multilang dict, we might get a string or a list of values, e.g. {'de': 'Dataset Title'} or {'de': ['tag1', 'tag2', 'tag3']}. If it's a string, we need to wrap it in a list so we can safely iterate over it in the next line - otherwise we iterate by letter: 'D', 'a', 't', ... Checking whether the value had the '__iter__' attribute worked for this in Python 2, but in Python 3, strings apparently also have this attribute. Let's just check whether the value is a list or not. If there are any other cases, we can catch them later!
# the values can be either a multilang-dict or they are | ||
# nested in another iterable (e.g. keywords) | ||
if not hasattr(values, "__iter__"): | ||
if not isinstance(values, list): |
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.
Apparently in Python 3, strings also have the __iter__
attribute. We need to really check whether the value is a list, not check for this attribute, or we won't correctly wrap a string value in a list (in the next line) and we'll end up iterating over it letter by letter.
I think there aren't any other kinds of iterable that we could get as a value here, only a list or a string, so this should be enough of a check here.
Let's get flake8 to look at everything else and fix these in a next step.
No description provided.