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
import enum
from hypothesis import example, given
from hypothesis import strategies as st
class MyFlag(enum.Flag):
ONE = 1
TWO = 2
@given(st.sampled_from(MyFlag))
@example(MyFlag.ONE | MyFlag.TWO)
def test_pretty_printing(flag: MyFlag):
assert isinstance(flag, MyFlag)
Tests fail with the following error message:
test_hypothesis_bug.py::test_pretty_printing Failed: [undefined]TypeError: can only concatenate str (not "NoneType") to str
@given(st.sampled_from(MyFlag))
> @example(MyFlag.ONE | MyFlag.TWO)
tests/unit/test_hypothesis_bug.py:13:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.10/site-packages/hypothesis/core.py:1056: in _raise_to_user
raise the_error_hypothesis_found
.venv/lib/python3.10/site-packages/hypothesis/core.py:470: in execute_explicit_examples
bits = ", ".join(nicerepr(x) for x in arguments) + ", ".join(
.venv/lib/python3.10/site-packages/hypothesis/core.py:471: in <genexpr>
f"{k}={nicerepr(v)}" for k, v in example_kwargs.items()
.venv/lib/python3.10/site-packages/hypothesis/internal/reflection.py:452: in nicerepr
return re.sub(r"(\[)~([A-Z][a-z]*\])", r"\g<1>\g<2>", pretty(v))
.venv/lib/python3.10/site-packages/hypothesis/vendor/pretty.py:101: in pretty
printer.pretty(obj)
.venv/lib/python3.10/site-packages/hypothesis/vendor/pretty.py:199: in pretty
return printer(obj, self, cycle)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
obj = <MyFlag.TWO|ONE: 3>
p = <hypothesis.vendor.pretty.RepresentationPrinter object at 0x7fc633f41090>
cycle = False
def _repr_enum(obj, p, cycle):
> p.text(type(obj).__name__ + "." + obj.name)
E TypeError: can only concatenate str (not "NoneType") to str
.venv/lib/python3.10/site-packages/hypothesis/vendor/pretty.py:804: TypeError
Root cause: mixed-value flags don't have a name.
Python 3.10
hypothesis 6.82.0
The text was updated successfully, but these errors were encountered:
Thanks for the report! This is a neat little bug, fortunately the solution should be pretty self-contained in that _repr_enum() function for whoever gets to it first.
A self-contained reproduction:
Tests fail with the following error message:
Root cause: mixed-value flags don't have a name.
Python 3.10
hypothesis 6.82.0
The text was updated successfully, but these errors were encountered: