当前位置: 首页>>代码示例>>Python>>正文


Python Tracker.track方法代码示例

本文整理汇总了Python中hypothesis.internal.tracker.Tracker.track方法的典型用法代码示例。如果您正苦于以下问题:Python Tracker.track方法的具体用法?Python Tracker.track怎么用?Python Tracker.track使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在hypothesis.internal.tracker.Tracker的用法示例。


在下文中一共展示了Tracker.track方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_track_complex_with_nan

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_track_complex_with_nan():
    t = Tracker()
    nan = float('nan')
    assert t.track(complex(nan, 2)) == 1
    assert t.track(complex(nan, 2)) == 2
    assert t.track(complex(0, nan)) == 1
    assert t.track(complex(0, nan)) == 2
    assert t.track(complex(nan, nan)) == 1
    assert t.track(complex(nan, nan)) == 2
开发者ID:untitaker,项目名称:hypothesis,代码行数:11,代码来源:test_tracker.py

示例2: test_can_track_morphers

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_can_track_morphers():
    t = Tracker()
    assert t.track(Morpher(0, 0)) == 1
    assert t.track(Morpher(0, 0)) == 2

    m1 = Morpher(0, 1)
    m2 = Morpher(0, 1)

    m1.become(s.lists(s.integers()))
    m2.become(s.lists(s.integers()))

    assert t.track(m1) == 1
    assert t.track(m2) == 2
开发者ID:trowt,项目名称:hypothesis,代码行数:15,代码来源:test_morpher.py

示例3: simplify_such_that

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
    def simplify_such_that(self, t, f):
        """Perform a greedy search to produce a "simplest" version of a
        template that satisfies some predicate.

        Care is taken to avoid cycles in simplify.

        f should produce the same result deterministically. This function may
        raise an error given f such that f(t) returns False sometimes and True
        some other times.

        """
        if not f(t):
            raise ValueError(
                '%r does not satisfy predicate %s' % (t, f))
        tracker = Tracker()
        yield t

        while True:
            simpler = self.simplify(t)
            for s in simpler:
                if tracker.track(s) > 1:
                    continue
                if f(s):
                    yield s
                    t = s
                    break
            else:
                break
开发者ID:mgedmin,项目名称:hypothesis,代码行数:30,代码来源:strategies.py

示例4: simplify_such_that

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
    def simplify_such_that(self, random, t, f, tracker=None):
        """Perform a greedy search to produce a "simplest" version of a
        template that satisfies some predicate.

        Care is taken to avoid cycles in simplify.

        f should produce the same result deterministically. This function may
        raise an error given f such that f(t) returns False sometimes and True
        some other times.

        """
        assert isinstance(random, Random)

        if tracker is None:
            tracker = Tracker()
        yield t

        changed = True
        while changed:
            changed = False
            for simplify in self.simplifiers(t):
                while True:
                    simpler = simplify(random, t)
                    for s in simpler:
                        if tracker.track(s) > 1:
                            continue
                        if f(s):
                            changed = True
                            yield s
                            t = s
                            break
                    else:
                        break
开发者ID:saulshanabrook,项目名称:hypothesis,代码行数:35,代码来源:strategies.py

示例5: test_can_minimize_to_empty

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
 def test_can_minimize_to_empty(self, template, rnd):
     simplest = template
     tracker = Tracker()
     while True:
         for t in strat.full_simplify(rnd, simplest):
             if tracker.track(t) == 1:
                 simplest = t
                 break
         else:
             break
     assert list(strat.full_simplify(rnd, simplest)) == []
开发者ID:Bachmann1234,项目名称:hypothesis,代码行数:13,代码来源:strategytests.py

示例6: minimal_element

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def minimal_element(strategy, random):
    tracker = Tracker()
    element = some_template(strategy, random)
    while True:
        for new_element in strategy.full_simplify(random, element):
            if tracker.track(new_element) > 1:
                continue
            try:
                strategy.reify(new_element)
                element = new_element
                break
            except UnsatisfiedAssumption:
                pass
        else:
            break
    return element
开发者ID:subsetpark,项目名称:hypothesis,代码行数:18,代码来源:debug.py

示例7: falsify

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
    def falsify(
            self, hypothesis,
            *argument_types,
            **kwargs
    ):  # pylint: disable=too-many-locals,too-many-branches
        """
        Attempt to construct an example tuple x matching argument_types such
        that hypothesis(*x) returns a falsey value
        """
        teardown_example = kwargs.get('teardown_example') or (lambda x: None)
        setup_example = kwargs.get('setup_example') or (lambda: None)
        random = self.random
        if random is None:
            random = Random(
                function_digest(hypothesis)
            )

        build_context = BuildContext(random)

        search_strategy = strategy(argument_types, self.settings)
        storage = None
        if self.database is not None:
            storage = self.database.storage_for(argument_types)

        def falsifies(args):  # pylint: disable=missing-docstring
            example = None
            try:
                try:
                    setup_example()
                    example = search_strategy.reify(args)
                    return not hypothesis(*example)
                except UnsatisfiedAssumption:
                    return False
            finally:
                teardown_example(example)

        track_seen = Tracker()
        falsifying_examples = []
        if storage:
            for example in storage.fetch():
                track_seen.track(example)
                if falsifies(example):
                    falsifying_examples = [example]
                break

        satisfying_examples = 0
        timed_out = False
        max_examples = self.max_examples
        min_satisfying_examples = self.min_satisfying_examples

        parameter_source = ParameterSource(
            context=build_context, strategy=search_strategy,
            min_parameters=max(2, int(float(max_examples) / 10))
        )
        start_time = time.time()

        def time_to_call_it_a_day():
            """Have we exceeded our timeout?"""
            if self.timeout <= 0:
                return False
            return time.time() >= start_time + self.timeout

        for parameter in islice(
            parameter_source, max_examples - len(track_seen)
        ):
            if len(track_seen) >= search_strategy.size_upper_bound:
                break

            if falsifying_examples:
                break
            if time_to_call_it_a_day():
                break

            args = search_strategy.produce_template(
                build_context, parameter
            )

            if track_seen.track(args) > 1:
                parameter_source.mark_bad()
                continue
            try:
                setup_example()
                a = None
                try:
                    a = search_strategy.reify(args)
                    is_falsifying_example = not hypothesis(*a)
                finally:
                    teardown_example(a)
            except UnsatisfiedAssumption:
                parameter_source.mark_bad()
                continue
            satisfying_examples += 1
            if is_falsifying_example:
                falsifying_examples.append(args)
        run_time = time.time() - start_time
        timed_out = self.timeout >= 0 and run_time >= self.timeout
        if not falsifying_examples:
            if (
                satisfying_examples and
                len(track_seen) >= search_strategy.size_lower_bound
#.........这里部分代码省略.........
开发者ID:saulshanabrook,项目名称:hypothesis,代码行数:103,代码来源:verifier.py

示例8: test_track_nan

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_track_nan():
    t = Tracker()
    assert t.track(float('nan')) == 1
    assert t.track(float('nan')) == 2
开发者ID:untitaker,项目名称:hypothesis,代码行数:6,代码来源:test_tracker.py

示例9: test_nested_unhashables

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_nested_unhashables():
    t = Tracker()
    x = {'foo': [1, 2, set((3, 4, 5, 6))], 'bar': 10}
    assert t.track(x) == 1
    assert t.track(x) == 2
开发者ID:untitaker,项目名称:hypothesis,代码行数:7,代码来源:test_tracker.py

示例10: test_track_dict

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_track_dict():
    t = Tracker()
    assert t.track({1: 2}) == 1
    assert t.track({1: 3}) == 1
开发者ID:untitaker,项目名称:hypothesis,代码行数:6,代码来源:test_tracker.py

示例11: test_track_iterables

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_track_iterables():
    t = Tracker()
    assert t.track(iter([1])) == 1
    assert t.track(iter([1])) == 2
开发者ID:untitaker,项目名称:hypothesis,代码行数:6,代码来源:test_tracker.py

示例12: test_track_lists

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_track_lists():
    t = Tracker()
    assert t.track([1]) == 1
    assert t.track([1]) == 2
开发者ID:untitaker,项目名称:hypothesis,代码行数:6,代码来源:test_tracker.py

示例13: test_track_ints

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_track_ints():
    t = Tracker()
    assert t.track(1) == 1
    assert t.track(1) == 2
开发者ID:untitaker,项目名称:hypothesis,代码行数:6,代码来源:test_tracker.py

示例14: test_tracking_classes_of_custom

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_tracking_classes_of_custom():
    t = Tracker()
    assert t.track(Foo) == 1
    assert t.track(Foo) == 2
开发者ID:untitaker,项目名称:hypothesis,代码行数:6,代码来源:test_tracker.py

示例15: test_tracking_custom

# 需要导入模块: from hypothesis.internal.tracker import Tracker [as 别名]
# 或者: from hypothesis.internal.tracker.Tracker import track [as 别名]
def test_tracking_custom():
    t = Tracker()
    assert t.track(Foo()) == 1
    assert t.track(Foo()) == 2
开发者ID:untitaker,项目名称:hypothesis,代码行数:6,代码来源:test_tracker.py


注:本文中的hypothesis.internal.tracker.Tracker.track方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。