Beispiel #1
0
 def __init__(self, min_year, max_year):
     elements = self.nasty_dates
     if min_year is not None:
         elements = [d for d in elements if d.year >= min_year]
     if max_year is not None:
         elements = [d for d in elements if d.year <= max_year]
     SampledFromStrategy.__init__(
         self,
         elements=elements
     )
Beispiel #2
0
 def __init__(self):
     SampledFromStrategy.__init__(self,
                                  elements=[
                                      0.0,
                                      sys.float_info.min,
                                      -sys.float_info.min,
                                      float('inf'),
                                      -float('inf'),
                                      float('nan'),
                                  ])
Beispiel #3
0
    def __init__(self, allow_nan=True, allow_infinity=True):
        elements = [
            0.0, -0.0, sys.float_info.min, -sys.float_info.min,
            -sys.float_info.max, sys.float_info.max
        ]
        if allow_infinity:
            elements.extend([float('inf'), -float('inf')])
        if allow_nan:
            elements.extend([float('nan')])

        SampledFromStrategy.__init__(self, elements=elements)
Beispiel #4
0
 def __init__(self):
     SampledFromStrategy.__init__(
         self,
         elements=[
             0.0,
             sys.float_info.min,
             -sys.float_info.min,
             float('inf'),
             -float('inf'),
             float('nan'),
         ]
     )
Beispiel #5
0
 def __init__(self):
     SampledFromStrategy.__init__(
         self,
         elements=[
             0.0,
             -0.0,
             sys.float_info.min,
             -sys.float_info.min,
             -sys.float_info.max,
             sys.float_info.max,
             float("inf"),
             -float("inf"),
             float("nan"),
         ],
     )
Beispiel #6
0
def sampled_from(elements):
    """Returns a strategy which generates any value present in the iterable
    elements.

    Note that as with just, values will not be copied and thus you
    should be careful of using mutable data

    """

    from hypothesis.searchstrategy.misc import SampledFromStrategy, \
        JustStrategy
    elements = tuple(iter(elements))
    if not elements:
        raise InvalidArgument(
            u'sampled_from requires at least one value'
        )
    if len(elements) == 1:
        result = JustStrategy(elements[0])
    else:
        result = SampledFromStrategy(elements)
    return ReprWrapperStrategy(
        result, u'sampled_from((%s))' % (u', '.join(
            map(unicode_safe_repr, elements)
        ))
    )
Beispiel #7
0
    def __init__(self, allow_nan=True, allow_infinity=True):
        elements = [
            0.0,
            -0.0,
            sys.float_info.min,
            -sys.float_info.min,
            -sys.float_info.max,
            sys.float_info.max
        ]
        if allow_infinity:
            elements.extend([
                float('inf'),
                -float('inf')
            ])
        if allow_nan:
            elements.extend([
                float('nan')
            ])

        SampledFromStrategy.__init__(self, elements=elements)
Beispiel #8
0
def sampled_from(elements):
    """Returns a strategy which generates any value present in the iterable
    elements.

    Note that as with just, values will not be copied and thus you
    should be careful of using mutable data

    """

    from hypothesis.searchstrategy.misc import SampledFromStrategy
    elements = tuple(iter(elements))
    if not elements:
        raise InvalidArgument('sampled_from requires at least one value')
    if len(elements) == 1:
        return just(elements[0])
    return SampledFromStrategy(elements)
def sampled_from(elements):
    """Returns a strategy which generates any value present in the iterable
    elements.

    Note that as with just, values will not be copied and thus you
    should be careful of using mutable data.

    """

    from hypothesis.searchstrategy.misc import SampledFromStrategy, \
        JustStrategy
    from hypothesis.internal.conjecture.utils import check_sample
    elements = check_sample(elements)
    if not elements:
        return nothing()
    if len(elements) == 1:
        return JustStrategy(elements[0])
    return SampledFromStrategy(elements)
Beispiel #10
0
def sampled_from(elements):
    """Returns a strategy which generates any value present in the iterable
    elements.

    Note that as with just, values will not be copied and thus you
    should be careful of using mutable data

    """

    from hypothesis.searchstrategy.misc import SampledFromStrategy, \
        JustStrategy
    elements = tuple(iter(elements))
    if not elements:
        return nothing()
    if len(elements) == 1:
        return JustStrategy(elements[0])
    else:
        return SampledFromStrategy(elements)
Beispiel #11
0
 def reify(self, value):
     return SampledFromStrategy.reify(self, value)
Beispiel #12
0
 def reify(self, value):
     return SampledFromStrategy.reify(self, value)