# Path: tests/utils.py
# def simple_class(
#     eq=False,
#     order=False,
#     repr=False,
#     hash=False,
#     str=False,
#     slots=False,
#     frozen=False,
#     cache_hash=False,
# ):
# def simple_attr(
#     name,
#     default=NOTHING,
#     validator=None,
#     repr=True,
#     eq=True,
#     hash=None,
#     init=True,
#     converter=None,
#     kw_only=False,
#     inherited=False,
# ):
#     def test_returns_class(self):
#     def returns_distinct_classes(self):
# class TestSimpleClass(object):


import keyword
import string
import attr
from collections import OrderedDict
from hypothesis import strategies as st
from .utils import make_class
def maybe_underscore_prefix(source):
    """
    A generator to sometimes prepend an underscore.
    """
    to_underscore = False
    for val in source:
        yield val if not to_underscore else "_" + val
        to_underscore = not to_underscore


@st.composite
def _create_hyp_nested_strategy(draw, simple_class_strategy):
    """
    Create a recursive attrs class.

    Given a strategy for building (simpler) classes, create and return
    a strategy for building classes that have as an attribute: either just
    the simpler class, a list of simpler classes, a tuple of simpler classes,
    an ordered dict or a dict mapping the string "cls" to a simpler class.
    """
    cls = draw(simple_class_strategy)
    factories = [
        cls,
        lambda: [cls()],
        lambda: (cls(),),
        lambda: {"cls": cls()},
        lambda: OrderedDict([("cls", cls())]),
    ]
    factory = draw(st.sampled_from(factories))
    attrs = draw(list_of_attrs) + [attr.ib(default=attr.Factory(factory))]

# Path: tests/utils.py
# def simple_class(
#     eq=False,
#     order=False,
#     repr=False,
#     hash=False,
#     str=False,
#     slots=False,
#     frozen=False,
#     cache_hash=False,
# ):
# def simple_attr(
#     name,
#     default=NOTHING,
#     validator=None,
#     repr=True,
#     eq=True,
#     hash=None,
#     init=True,
#     converter=None,
#     kw_only=False,
#     inherited=False,
# ):
#     def test_returns_class(self):
#     def returns_distinct_classes(self):
# class TestSimpleClass(object):


# Path: tests/strategies.py
import keyword
import string
import attr
from collections import OrderedDict
from hypothesis import strategies as st
from .utils import make_class

def maybe_underscore_prefix(source):
    """
    A generator to sometimes prepend an underscore.
    """
    to_underscore = False
    for val in source:
        yield val if not to_underscore else "_" + val
        to_underscore = not to_underscore


@st.composite
def _create_hyp_nested_strategy(draw, simple_class_strategy):
    """
    Create a recursive attrs class.

    Given a strategy for building (simpler) classes, create and return
    a strategy for building classes that have as an attribute: either just
    the simpler class, a list of simpler classes, a tuple of simpler classes,
    an ordered dict or a dict mapping the string "cls" to a simpler class.
    """
    cls = draw(simple_class_strategy)
    factories = [
        cls,
        lambda: [cls()],
        lambda: (cls(),),
        lambda: {"cls": cls()},
        lambda: OrderedDict([("cls", cls())]),
    ]
    factory = draw(st.sampled_from(factories))
    attrs = draw(list_of_attrs) + [attr.ib(default=attr.Factory(factory))]

    return make_class("HypClass", dict(zip(gen_attr_names(), attrs)))