You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
language_tags is described as being an iterable, however this is not strictly true, as passing a dict (with languages as keys) will break the call for example.
See the test bellow for an actual example
I'm guessing the actual type is a Sequence instead
fromunittest.mockimportMockfromwebob.acceptparseimportAcceptLanguageValidHeaderdeftest_lookup_ok():
languages= ('en', 'fr')
header=AcceptLanguageValidHeader('fr, *')
assertheader.lookup(languages, default='fallback') =='fr'deftest_lookup_ko():
languages=dict.fromkeys(('en', 'fr'))
forkeyinlanguages:
# Real world: associate with a gettext instancelanguages[key] =Mock()
header=AcceptLanguageValidHeader('fr, *')
assertheader.lookup(languages, default='fallback') =='fr'""" <<< output <<<<<<____________________ test_lookup_ko ____________________ def test_lookup_ko(): known = dict.fromkeys(('en', 'fr')) for key in known: # Real world: associate with a gettext instance known[key] = Mock() header = AcceptLanguageValidHeader('fr, *')> assert header.lookup(known, default='fallback') == 'fr'test_accept.py:23: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _.../webob/acceptparse.py:4686: in lookup match = best_match(range_=range_.lower())_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _range_ = 'fr' def best_match(range_): subtags = range_.split('-') while True: for index, tag in enumerate(lowered_tags): if tag in not_acceptable_ranges: continue # We think a non-'*' range with q=0 represents only # itself as a tag, and there should be no falling back # with subtag truncation. For example, with # 'en-gb;q=0', it should not mean 'en;q=0': the client # is unlikely to expect that specifying 'en-gb' as not # acceptable would mean that 'en' is also not # acceptable. There is no guidance on this at all in # the RFCs, so it is left to us to decide how it should # work. if tag == range_:> return tags[index] # return the pre-lowered tagE KeyError: 1.../webob/acceptparse.py:4670: KeyError================ short test summary info ================FAILED test_accept.py::test_lookup_ko - KeyError: 1"""
The text was updated successfully, but these errors were encountered:
URL of the documentation: https://docs.pylonsproject.org/projects/webob/en/stable/api/webob.html#webob.acceptparse.AcceptLanguageValidHeader.lookup
language_tags
is described as being an iterable, however this is not strictly true, as passing a dict (with languages as keys) will break the call for example.See the test bellow for an actual example
I'm guessing the actual type is a Sequence instead
The text was updated successfully, but these errors were encountered: