コード例 #1
0
ファイル: strategies.py プロジェクト: jsoref/hypothesis
 def __call__(self, values):
     if not values:
         raise IndexError('Cannot choose from empty sequence')
     result = choice(self.data, values)
     with self.build_context.local():
         self.choice_count += 1
         note('Choice #%d: %r' % (self.choice_count, result))
     return result
コード例 #2
0
 def __call__(self, values):
     if not values:
         raise IndexError('Cannot choose from empty sequence')
     result = choice(self.data, check_sample(values))
     with self.build_context.local():
         self.choice_count += 1
         note('Choice #%d: %r' % (self.choice_count, result))
     return result
コード例 #3
0
 def draw(self, strategy, label=None):
     self.data.mark_bind()
     result = self.data.draw(strategy)
     self.count += 1
     if label is not None:
         note('Draw %d (%s): %r' % (self.count, label, result))
     else:
         note('Draw %d: %r' % (self.count, result))
     return result
コード例 #4
0
ファイル: functions.py プロジェクト: wlof-2/Poetry_analysis
 def inner(*args, **kwargs):
     if data.frozen:
         raise InvalidState(
             "This generated %s function can only be called within the "
             "scope of the @given that created it." %
             (nicerepr(self.like), ))
     val = data.draw(self.returns)
     note("Called function: %s(%s) -> %r" % (nicerepr(
         self.like), arg_string(self.like, args, kwargs), val))
     return val
コード例 #5
0
 def inner(*args, **kwargs):
     if data.frozen:
         raise InvalidState(
             "This generated %s function can only be called within the "
             "scope of the @given that created it." % (nicerepr(self.like),)
         )
     data.can_reproduce_example_from_repr = False
     val = data.draw(self.returns)
     note(
         "Called function: %s(%s) -> %r"
         % (nicerepr(self.like), arg_string(self.like, args, kwargs), val)
     )
     return val
コード例 #6
0
ファイル: core.py プロジェクト: The-Compiler/hypothesis
    def run(data):
        from hypothesis.control import note

        with BuildContext(is_final=is_final):
            seed = data.draw(random_module()).seed
            if seed != 0:
                note("random.seed(%d)" % (seed,))
            args, kwargs = data.draw(search_strategy)

            if print_example:
                report(lambda: "Falsifying example: %s(%s)" % (test.__name__, arg_string(test, args, kwargs)))
            elif current_verbosity() >= Verbosity.verbose:
                report(lambda: "Trying example: %s(%s)" % (test.__name__, arg_string(test, args, kwargs)))
            return test(*args, **kwargs)
コード例 #7
0
 def inner(*args, **kwargs):
     if data.frozen:
         raise InvalidState(
             "This generated %s function can only be called within the "
             "scope of the @given that created it." %
             (nicerepr(self.like), ))
     if self.pure:
         args, kwargs = convert_positional_arguments(
             self.like, args, kwargs)
         key = (inner, args, frozenset(kwargs.items()))
         val = data.draw(SharedStrategy(base=self.returns, key=key))
     else:
         val = data.draw(self.returns)
     note("Called function: %s(%s) -> %r" % (nicerepr(
         self.like), arg_string(self.like, args, kwargs), val))
     return val
コード例 #8
0
ファイル: core.py プロジェクト: mgomezch/hypothesis
    def run(data):
        from hypothesis.control import note

        with BuildContext(is_final=is_final):
            seed = data.draw(random_module()).seed
            if seed != 0:
                note('random.seed(%d)' % (seed, ))
            args, kwargs = data.draw(search_strategy)

            if print_example:
                report(lambda: 'Falsifying example: %s(%s)' %
                       (test.__name__, arg_string(test, args, kwargs)))
            elif current_verbosity() >= Verbosity.verbose:
                report(lambda: 'Trying example: %s(%s)' %
                       (test.__name__, arg_string(test, args, kwargs)))
            return test(*args, **kwargs)
コード例 #9
0
ファイル: strategies.py プロジェクト: zooming-tan/hypothesis
 def choice(values):
     if not values:
         raise IndexError('Cannot choose from empty sequence')
     k = len(values) - 1
     if k == 0:
         chosen = 0
     else:
         mask = _right_saturate(k)
         while True:
             index[0] += 1
             probe = stream[index[0]] & mask
             if probe <= k:
                 chosen = probe
                 break
     choice_count[0] += 1
     result = values[chosen]
     with context.local():
         note('Choice #%d: %r' % (choice_count[0], result))
     return result
コード例 #10
0
ファイル: strategies.py プロジェクト: tokenrove/hypothesis
 def choice(values):
     if not values:
         raise IndexError('Cannot choose from empty sequence')
     k = len(values) - 1
     if k == 0:
         chosen = 0
     else:
         mask = _right_saturate(k)
         while True:
             index[0] += 1
             probe = stream[index[0]] & mask
             if probe <= k:
                 chosen = probe
                 break
     choice_count[0] += 1
     result = values[chosen]
     with context.local():
         note('Choice #%d: %r' % (choice_count[0], result))
     return result
コード例 #11
0
ファイル: functions.py プロジェクト: jjpal/hypothesis
 def inner(*args, **kwargs):
     if data.frozen:
         raise InvalidState(
             f"This generated {nicerepr(self.like)} function can only "
             "be called within the scope of the @given that created it."
         )
     if self.pure:
         args, kwargs = convert_positional_arguments(
             self.like, args, kwargs)
         key = (args, frozenset(kwargs.items()))
         cache = self._cache.setdefault(inner, {})
         if key not in cache:
             cache[key] = data.draw(self.returns)
             rep = repr_call(self.like, args, kwargs, reorder=False)
             note(f"Called function: {rep} -> {cache[key]!r}")
         return cache[key]
     else:
         val = data.draw(self.returns)
         rep = repr_call(self.like, args, kwargs, reorder=False)
         note(f"Called function: {rep} -> {val!r}")
         return val
コード例 #12
0
 def test(x):
     generated_integers.append(x)
     note(notefmt(x))
     assert x < 5
コード例 #13
0
 def test(x):
     msg = 'x -> %d' % (x,)
     note(msg)
     messages.add(msg)
     assert x < 5
コード例 #14
0
def test_raises_if_note_out_of_context():
    with pytest.raises(InvalidArgument):
        note('Hi')
コード例 #15
0
ファイル: test_control.py プロジェクト: vlulla/hypothesis
 def test(x):
     msg = f"x -> {x}"
     note(msg)
     messages.add(msg)
     assert x < 5
コード例 #16
0
ファイル: strategies.py プロジェクト: jsoref/hypothesis
 def draw(self, strategy):
     result = self.data.draw(strategy)
     self.count += 1
     note('Draw %d: %r' % (self.count, result))
     return result
コード例 #17
0
 def test(x):
     msg = 'x -> %d' % (x, )
     note(msg)
     messages.add(msg)
     assert x < 5
コード例 #18
0
def test_raises_if_note_out_of_context():
    with pytest.raises(InvalidArgument):
        note('Hi')
コード例 #19
0
ファイル: strategies.py プロジェクト: mgomezch/hypothesis
 def draw(self, strategy):
     result = self.data.draw(strategy)
     self.count += 1
     note('Draw %d: %r' % (self.count, result))
     return result