Page MenuHomeSoftware Heritage

Jenkins > .tox.py3-full.lib.python3.7.site-packages.swh.model.tests.test_model::test_todict_inverse_fromdict
Failed

TEST RESULT

Run At
Jun 18 2021, 11:20 AM
Details
@given(strategies.objects()) > def test_todict_inverse_fromdict(objtype_and_obj): .tox/py3-full/lib/python3.7/site-packages/swh/model/tests/test_model.py:66: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3-full/lib/python3.7/site-packages/hypothesis/core.py:450: in process_arguments_to_given search_strategy.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:46: in do_validate s.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:800: in do_validate self.mapped_strategy.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:135: in do_validate w.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:800: in do_validate self.mapped_strategy.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:46: in do_validate s.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:657: in do_validate e.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:800: in do_validate self.mapped_strategy.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:135: in do_validate w.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:800: in do_validate self.mapped_strategy.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:135: in do_validate w.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:46: in do_validate s.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:800: in do_validate self.mapped_strategy.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:46: in do_validate s.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:657: in do_validate e.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:135: in do_validate w.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:800: in do_validate self.mapped_strategy.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:135: in do_validate w.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:46: in do_validate s.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:800: in do_validate self.mapped_strategy.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/collections.py:46: in do_validate s.validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:400: in validate self.do_validate() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:656: in do_validate for e in self.element_strategies: .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:632: in element_strategies for s in arg.branches: .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:664: in branches return self.element_strategies .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:631: in element_strategies if not arg.is_empty: .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:135: in accept recur(self) .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:131: in recur mapping[strat] = getattr(strat, calculation)(recur) .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/lazy.py:92: in calc_is_empty return recur(self.wrapped_strategy) .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/strategies.py:131: in recur mapping[strat] = getattr(strat, calculation)(recur) .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/deferred.py:70: in calc_is_empty return recur(self.wrapped_strategy) .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/deferred.py:40: in wrapped_strategy result = self.__definition() .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/core.py:947: in <lambda> lambda thing: deferred(lambda: _from_type(thing)), .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/core.py:1057: in _from_type return types.from_typing_type(thing) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ thing = swh.model.collections.ImmutableDict[~KT, ~VT] def from_typing_type(thing): # We start with special-case support for Union and Tuple - the latter # isn't actually a generic type. Then we handle Literal since it doesn't # support `isinstance`. # # We then explicitly error on non-Generic types, which don't carry enough # information to sensibly resolve to strategies at runtime. # Finally, we run a variation of the subclass lookup in `st.from_type` # among generic types in the lookup. if getattr(thing, "__origin__", None) == tuple or isinstance( thing, getattr(typing, "TupleMeta", ()) ): elem_types = getattr(thing, "__tuple_params__", None) or () elem_types += getattr(thing, "__args__", None) or () if ( getattr(thing, "__tuple_use_ellipsis__", False) or len(elem_types) == 2 and elem_types[-1] is Ellipsis ): return st.lists(st.from_type(elem_types[0])).map(tuple) elif len(elem_types) == 1 and elem_types[0] == (): return st.tuples() # Empty tuple; see issue #1583 return st.tuples(*map(st.from_type, elem_types)) if hasattr(typing, "Final") and getattr(thing, "__origin__", None) == typing.Final: return st.one_of([st.from_type(t) for t in thing.__args__]) if is_typing_literal(thing): args_dfs_stack = list(thing.__args__) literals = [] while args_dfs_stack: arg = args_dfs_stack.pop() if is_typing_literal(arg): args_dfs_stack.extend(reversed(arg.__args__)) else: literals.append(arg) return st.sampled_from(literals) if is_annotated_type(thing): # pragma: no cover # This requires Python 3.9+ or the typing_extensions package args = thing.__args__ assert args, "it's impossible to make an annotated type with no args" annotated_type = args[0] return st.from_type(annotated_type) # Now, confirm that we're dealing with a generic type as we expected if sys.version_info[:2] < (3, 9) and not isinstance( thing, typing_root_type ): # pragma: no cover raise ResolutionFailed(f"Cannot resolve {thing} to a strategy") # Some "generic" classes are not generic *in* anything - for example both # Hashable and Sized have `__args__ == ()` on Python 3.7 or later. # (In 3.6 they're just aliases for the collections.abc classes) origin = getattr(thing, "__origin__", thing) if ( typing.Hashable is not collections.abc.Hashable and origin in vars(collections.abc).values() and len(getattr(thing, "__args__", None) or []) == 0 ): return st.from_type(origin) # Parametrised generic types have their __origin__ attribute set to the # un-parametrised version, which we need to use in the subclass checks. # e.g.: typing.List[int].__origin__ == typing.List mapping = { k: v for k, v in _global_type_lookup.items() if is_generic_type(k) and try_issubclass(k, thing) } if typing.Dict in mapping or typing.Set in mapping: # ItemsView can cause test_lookup.py::test_specialised_collection_types # to fail, due to weird isinstance behaviour around the elements. mapping.pop(typing.ItemsView, None) if sys.version_info[:2] == (3, 6): # pragma: no cover # `isinstance(dict().values(), Container) is False` on py36 only -_- mapping.pop(typing.ValuesView, None) if typing.Deque in mapping and len(mapping) > 1: # Resolving generic sequences to include a deque is more trouble for e.g. # the ghostwriter than it's worth, via undefined names in the repr. mapping.pop(typing.Deque) if len(mapping) > 1: # issubclass treats bytestring as a kind of sequence, which it is, # but treating it as such breaks everything else when it is presumed # to be a generic sequence or container that could hold any item. # Except for sequences of integers, or unions which include integer! # See https://github.com/HypothesisWorks/hypothesis/issues/2257 # # This block drops ByteString from the types that can be generated # if there is more than one allowed type, and the element type is # not either `int` or a Union with `int` as one of its elements. elem_type = (getattr(thing, "__args__", None) or ["not int"])[0] if getattr(elem_type, "__origin__", None) is typing.Union: union_elems = elem_type.__args__ else: union_elems = () if not any( isinstance(T, type) and issubclass(int, T) for T in list(union_elems) + [elem_type] ): mapping.pop(typing.ByteString, None) elif ( (not mapping) and isinstance(thing, ForwardRef) and thing.__forward_arg__ in vars(builtins) ): return st.from_type(getattr(builtins, thing.__forward_arg__)) strategies = [ v if isinstance(v, st.SearchStrategy) else v(thing) for k, v in mapping.items() if sum(try_issubclass(k, T) for T in mapping) == 1 ] empty = ", ".join(repr(s) for s in strategies if s.is_empty) if empty or not strategies: raise ResolutionFailed( "Could not resolve %s to a strategy; consider using " > "register_type_strategy" % (empty or thing,) ) E hypothesis.errors.ResolutionFailed: Could not resolve swh.model.collections.ImmutableDict[~KT, ~VT] to a strategy; consider using register_type_strategy .tox/py3-full/lib/python3.7/site-packages/hypothesis/strategies/_internal/types.py:297: ResolutionFailed