[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1001538: python-hypothesis: test failures with python3.10



Source: python-hypothesis
Version: 5.43.3-1
Severity: serious
Tag: bookworm sid ftbfs
X-Debbugs-CC: debian-ci@lists.debian.org
User: debian-ci@lists.debian.org
Usertags: needs-update
User: debian-python@lists.debian.org
Usertags: python3.10
Control: affects -1 src:python3-defaults

Hi Maintainer

As can be seen in autopkgtests [1] and reproducible builds [2], the
tests of python-hypothesis fail when python3.10 is a supported
version.  This currently blocks the migration of python3-defaults to
testing [3].

I've copied what I hope is the relevant part of the log below.

Regards
Graham


[1] https://ci.debian.net/packages/p/python-hypothesis/unstable/amd64/
[2] https://tests.reproducible-builds.org/debian/rb-pkg/python-hypothesis.html
[3] https://qa.debian.org/excuses.php?package=python3-defaults


=================================== FAILURES ===================================
____________________________ test_resolves_NewType _____________________________

    def test_resolves_NewType():
        typ = typing.NewType("T", int)
        nested = typing.NewType("NestedT", typ)
        uni = typing.NewType("UnionT", typing.Optional[int])
>       assert isinstance(from_type(typ).example(), int)

tests/cover/test_lookup.py:448:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:314:
in example
    example_generating_inner_function()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:302:
in example_generating_inner_function
    @settings(
/usr/lib/python3/dist-packages/hypothesis/core.py:441: in
process_arguments_to_given
    search_strategy.validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:377:
in validate
    self.do_validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/collections.py:39:
in do_validate
    s.validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:377:
in validate
    self.do_validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:638:
in do_validate
    self.mapped_strategy.validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:377:
in validate
    self.do_validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/lazy.py:118:
in do_validate
    w.validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:377:
in validate
    self.do_validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:638:
in do_validate
    self.mapped_strategy.validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:377:
in validate
    self.do_validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/collections.py:39:
in do_validate
    s.validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:377:
in validate
    self.do_validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/lazy.py:118:
in do_validate
    w.validate()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:378:
in validate
    self.is_empty
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:125:
in accept
    recur(self)
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/strategies.py:121:
in recur
    mapping[strat] = getattr(strat, calculation)(recur)
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/deferred.py:80:
in calc_is_empty
    return recur(self.wrapped_strategy)
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/deferred.py:43:
in wrapped_strategy
    result = self.__definition()
/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/core.py:1417:
in <lambda>
    lambda thing: deferred(lambda: _from_type(thing)),
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

thing = tests.cover.test_lookup.T

    def _from_type(thing: Type[Ex]) -> SearchStrategy[Ex]:
        # TODO: We would like to move this to the top level, but
pending some major
        # refactoring it's hard to do without creating circular imports.
        from hypothesis.strategies._internal import types

        if (
            hasattr(typing, "_TypedDictMeta")
            and type(thing) is typing._TypedDictMeta  # type: ignore
            or hasattr(types.typing_extensions, "_TypedDictMeta")
            and type(thing) is types.typing_extensions._TypedDictMeta
# type: ignore
        ):  # pragma: no cover
            # The __optional_keys__ attribute may or may not be
present, but if there's no
            # way to tell and we just have to assume that everything
is required.
            # See https://github.com/python/cpython/pull/17214 for details.
            optional = getattr(thing, "__optional_keys__", ())
            anns = {k: from_type(v) for k, v in thing.__annotations__.items()}
            return fixed_dictionaries(  # type: ignore
                mapping={k: v for k, v in anns.items() if k not in optional},
                optional={k: v for k, v in anns.items() if k in optional},
            )

        def as_strategy(strat_or_callable, thing, final=True):
            # User-provided strategies need some validation, and
callables even more
            # of it.  We do this in three places, hence the helper function
            if not isinstance(strat_or_callable, SearchStrategy):
                assert callable(strat_or_callable)  # Validated in
register_type_strategy
                try:
                    # On Python 3.6, typing.Hashable is just an alias
for abc.Hashable,
                    # and the resolver function for Type throws an
AttributeError because
                    # Hashable has no __args__.  We discard such
errors when attempting
                    # to resolve subclasses, because the function was
passed a weird arg.
                    strategy = strat_or_callable(thing)
                except Exception:  # pragma: no cover
                    if not final:
                        return NOTHING
                    raise
            else:
                strategy = strat_or_callable
            if not isinstance(strategy, SearchStrategy):
                raise ResolutionFailed(
                    "Error: %s was registered for %r, but returned
non-strategy %r"
                    % (thing, nicerepr(strat_or_callable), strategy)
                )
            if strategy.is_empty:
                raise ResolutionFailed("Error: %r resolved to an empty
strategy" % (thing,))
            return strategy

        if not isinstance(thing, type):
            if types.is_a_new_type(thing):
                # Check if we have an explicitly registered strategy
for this thing,
                # resolve it so, and otherwise resolve as for the base type.
                if thing in types._global_type_lookup:
                    return as_strategy(types._global_type_lookup[thing], thing)
                return from_type(thing.__supertype__)
            # Under Python 3.6, Unions are not instances of `type` - but we
            # still want to resolve them!
            if getattr(thing, "__origin__", None) is typing.Union:
                args = sorted(thing.__args__, key=types.type_sorting_key)
                return one_of([from_type(t) for t in args])
        if not types.is_a_type(thing):
>           raise InvalidArgument("thing=%s must be a type" % (thing,))
E           hypothesis.errors.InvalidArgument:
thing=tests.cover.test_lookup.T must be a type

/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/core.py:1484:
InvalidArgument
__________________________ test_can_register_NewType ___________________________

    def test_can_register_NewType():
        Name = typing.NewType("Name", str)
>       st.register_type_strategy(Name, st.just("Eric Idle"))

tests/cover/test_lookup.py:549:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

custom_type = tests.cover.test_lookup.Name, strategy = just('Eric Idle')

    def register_type_strategy(
        custom_type: Type[Ex],
        strategy: Union[SearchStrategy[Ex], Callable[[Type[Ex]],
SearchStrategy[Ex]]],
    ) -> None:
        """Add an entry to the global type-to-strategy lookup.

        This lookup is used in :func:`~hypothesis.strategies.builds` and
        :func:`@given <hypothesis.given>`.

        :func:`~hypothesis.strategies.builds` will be used automatically for
        classes with type annotations on ``__init__`` , so you only need to
        register a strategy if one or more arguments need to be more tightly
        defined than their type-based default, or if you want to
supply a strategy
        for an argument with a default value.

        ``strategy`` may be a search strategy, or a function that
takes a type and
        returns a strategy (useful for generic types).

        Note that you may not register a parametrised generic type (such as
        ``MyCollection[int]``) directly, because the resolution logic does not
        handle this case correctly.  Instead, you may register a *function* for
        ``MyCollection`` and `inspect the type parameters within that function
        <https://stackoverflow.com/q/48572831>`__.
        """
        # TODO: We would like to move this to the top level, but
pending some major
        # refactoring it's hard to do without creating circular imports.
        from hypothesis.strategies._internal import types

        if not types.is_a_type(custom_type):
>           raise InvalidArgument("custom_type=%r must be a type")
E           hypothesis.errors.InvalidArgument: custom_type=%r must be a type

/usr/lib/python3/dist-packages/hypothesis/strategies/_internal/core.py:2151:
InvalidArgument
_______________________ test_pprint_heap_allocated_type ________________________

    @skip_without("xxlimited")
    def test_pprint_heap_allocated_type():
        """Test that pprint works for heap allocated types."""
        import xxlimited

>       output = pretty.pretty(xxlimited.Null)
E       AttributeError: module 'xxlimited' has no attribute 'Null'

tests/cover/test_pretty.py:275: AttributeError


Reply to: