How to use is_exhausted method in hypothesis

Best Python code snippet using hypothesis

datatree.py

Source:datatree.py Github

copy

Full Screen

...152 objects, for use in ConjectureRunner."""153 def __init__(self):154 self.root = TreeNode()155 @property156 def is_exhausted(self):157 """Returns True if every possible node is dead and thus the language158 described must have been fully explored."""159 return self.root.is_exhausted160 def generate_novel_prefix(self, random):161 """Generate a short random string that (after rewriting) is not162 a prefix of any buffer previously added to the tree.163 The resulting prefix is essentially arbitrary - it would be nice164 for it to be uniform at random, but previous attempts to do that165 have proven too expensive.166 """167 assert not self.is_exhausted168 novel_prefix = bytearray()169 def append_int(n_bits, value):170 novel_prefix.extend(int_to_bytes(value, bits_to_bytes(n_bits)))...

Full Screen

Full Screen

test_WritesRetry.py

Source:test_WritesRetry.py Github

copy

Full Screen

...24 self.assertEqual(retry.exponential_base, 3)25 self.assertEqual(retry.total, 8)26 def test_backoff_max_time(self):27 retry = NonRandomMinWritesRetry(max_retry_time=2)28 self.assertEqual(retry.is_exhausted(), False)29 self.assertEqual(retry.get_backoff_time(), 0)30 retry = retry.increment()31 self.assertEqual(retry.is_exhausted(), False)32 self.assertEqual(retry.get_backoff_time(), 5)33 retry = retry.increment()34 self.assertEqual(retry.is_exhausted(), False)35 self.assertEqual(retry.get_backoff_time(), 10)36 time.sleep(3)37 with self.assertRaises(MaxRetryError) as cm:38 retry.increment()39 exception = cm.exception40 self.assertEqual("max_retry_time exceeded", exception.reason.args[0])41 def test_backoff_start_range(self):42 retry = NonRandomMinWritesRetry(total=5, retry_interval=1, exponential_base=2,43 max_retry_delay=550)44 self.assertEqual(retry.total, 5)45 self.assertEqual(retry.is_exhausted(), False)46 self.assertEqual(retry.get_backoff_time(), 0)47 retry = retry.increment()48 self.assertEqual(retry.total, 4)49 self.assertEqual(retry.is_exhausted(), False)50 self.assertEqual(retry.get_backoff_time(), 1)51 retry = retry.increment()52 self.assertEqual(retry.total, 3)53 self.assertEqual(retry.is_exhausted(), False)54 self.assertEqual(retry.get_backoff_time(), 2)55 retry = retry.increment()56 self.assertEqual(retry.total, 2)57 self.assertEqual(retry.is_exhausted(), False)58 self.assertEqual(retry.get_backoff_time(), 4)59 retry = retry.increment()60 self.assertEqual(retry.total, 1)61 self.assertEqual(retry.is_exhausted(), False)62 self.assertEqual(retry.get_backoff_time(), 8)63 retry = retry.increment()64 self.assertEqual(retry.total, 0)65 self.assertEqual(retry.is_exhausted(), False)66 self.assertEqual(retry.get_backoff_time(), 16)67 with self.assertRaises(MaxRetryError) as cm:68 retry.increment()69 exception = cm.exception70 self.assertEqual("too many error responses", exception.reason.args[0])71 def test_backoff_stop_range(self):72 retry = NonRandomMaxWritesRetry(total=5, retry_interval=5, exponential_base=2,73 max_retry_delay=550)74 self.assertEqual(retry.total, 5)75 self.assertEqual(retry.is_exhausted(), False)76 self.assertEqual(retry.get_backoff_time(), 0)77 retry = retry.increment()78 self.assertEqual(retry.total, 4)79 self.assertEqual(retry.is_exhausted(), False)80 self.assertEqual(retry.get_backoff_time(), 10)81 retry = retry.increment()82 self.assertEqual(retry.total, 3)83 self.assertEqual(retry.is_exhausted(), False)84 self.assertEqual(retry.get_backoff_time(), 20)85 retry = retry.increment()86 self.assertEqual(retry.total, 2)87 self.assertEqual(retry.is_exhausted(), False)88 self.assertEqual(retry.get_backoff_time(), 40)89 retry = retry.increment()90 self.assertEqual(retry.total, 1)91 self.assertEqual(retry.is_exhausted(), False)92 self.assertEqual(retry.get_backoff_time(), 80)93 retry = retry.increment()94 self.assertEqual(retry.total, 0)95 self.assertEqual(retry.is_exhausted(), False)96 self.assertEqual(retry.get_backoff_time(), 160)97 with self.assertRaises(MaxRetryError) as cm:98 retry.increment()99 exception = cm.exception100 self.assertEqual("too many error responses", exception.reason.args[0])101 def test_backoff_max(self):102 retry = WritesRetry(total=5, retry_interval=1, max_retry_delay=15) \103 .increment() \104 .increment() \105 .increment() \106 .increment() \107 .increment()108 self.assertLessEqual(retry.get_backoff_time(), 15)109 def test_backoff_increment(self):110 retry = WritesRetry(total=5, retry_interval=4).increment()111 self.assertEqual(retry.total, 4)112 self.assertEqual(retry.is_exhausted(), False)113 backoff_time = retry.get_backoff_time()114 self.assertGreater(backoff_time, 4)115 self.assertLessEqual(backoff_time, 8)116 def test_backoff_exponential_base(self):117 retry = NonRandomMinWritesRetry(total=5, retry_interval=2, exponential_base=2)118 retry = retry.increment()119 self.assertEqual(retry.get_backoff_time(), 2)120 retry = retry.increment()121 self.assertEqual(retry.get_backoff_time(), 4)122 retry = retry.increment()123 self.assertEqual(retry.get_backoff_time(), 8)124 retry = retry.increment()125 self.assertEqual(retry.get_backoff_time(), 16)126 def test_get_retry_after(self):...

Full Screen

Full Screen

test_lazy_tuple.py

Source:test_lazy_tuple.py Github

copy

Full Screen

1# Copyright 2009-2017 Ram Rachum.2# This program is distributed under the MIT license.3'''Testing module for `python_toolbox.nifty_collections.LazyTuple`.'''4from __future__ import generator_stop5import uuid6import itertools7import collections8from python_toolbox import cute_iter_tools9from python_toolbox import sequence_tools10from python_toolbox import cute_testing11from python_toolbox.nifty_collections import LazyTuple12class SelfAwareUuidIterator(collections.abc.Iterator):13 '''Iterator that gives UUIDs and keeps them all in an internal list.'''14 def __init__(self):15 self.data = []16 def __next__(self):17 new_entry = uuid.uuid4()18 self.data.append(new_entry)19 return new_entry20def test():21 '''Test the basic workings of `LazyTuple`.'''22 self_aware_uuid_iterator = SelfAwareUuidIterator()23 lazy_tuple = LazyTuple(self_aware_uuid_iterator)24 assert len(self_aware_uuid_iterator.data) == 025 assert not lazy_tuple.is_exhausted26 assert repr(lazy_tuple) == '<LazyTuple: (...)>'27 first = lazy_tuple[0]28 assert len(self_aware_uuid_iterator.data) == 129 assert isinstance(first, uuid.UUID)30 assert first == self_aware_uuid_iterator.data[0]31 first_ten = lazy_tuple[:10]32 assert isinstance(first_ten, tuple)33 assert len(self_aware_uuid_iterator.data) == 1034 assert first_ten[0] == first35 assert all(isinstance(item, uuid.UUID) for item in first_ten)36 weird_slice = lazy_tuple[15:5:-3]37 assert isinstance(first_ten, tuple)38 assert len(self_aware_uuid_iterator.data) == 1639 assert len(weird_slice) == 440 assert weird_slice[2] == first_ten[-1] == lazy_tuple[9]41 assert not lazy_tuple.is_exhausted42 iterator_twenty = cute_iter_tools.shorten(lazy_tuple, 20)43 assert len(self_aware_uuid_iterator.data) == 1644 first_twenty = list(iterator_twenty)45 assert len(self_aware_uuid_iterator.data) == 2046 assert len(first_twenty) == 2047 assert first_twenty[:10] == list(first_ten)48 assert first_twenty == self_aware_uuid_iterator.data49 iterator_twelve = cute_iter_tools.shorten(lazy_tuple, 12)50 first_twelve = list(iterator_twelve)51 assert len(self_aware_uuid_iterator.data) == 2052 assert len(first_twelve) == 1253 assert first_twenty[:12] == first_twelve54 assert bool(lazy_tuple) == True55def test_empty():56 '''Test an empty `LazyTuple`.'''57 def empty_generator():58 if False: yield # (Unreachable `yield` to make this a generator.)59 return60 lazy_tuple = LazyTuple(empty_generator())61 assert repr(lazy_tuple) == '<LazyTuple: (...)>'62 with cute_testing.RaiseAssertor(IndexError):63 lazy_tuple[7]64 assert repr(lazy_tuple) == '<LazyTuple: []>'65 assert bool(LazyTuple(())) == False66 assert bool(lazy_tuple) == False67def test_string():68 '''Test a `LazyTuple` built from a string.'''69 string = 'meow'70 lazy_tuple = LazyTuple(string)71 assert lazy_tuple.is_exhausted72 assert repr(lazy_tuple) == "<LazyTuple: 'meow'>"73 assert ''.join(lazy_tuple) == string74 assert ''.join(lazy_tuple[1:-1]) == string[1:-1]75 assert len(lazy_tuple) == lazy_tuple.known_length == \76 len(lazy_tuple.collected_data)77 assert LazyTuple(reversed(LazyTuple(reversed(lazy_tuple)))) == lazy_tuple78def test_infinite():79 '''Test an infinite `LazyTuple`.'''80 lazy_tuple = LazyTuple(itertools.count())81 assert not lazy_tuple.is_exhausted82 lazy_tuple[100]83 assert len(lazy_tuple.collected_data) == 10184 assert not lazy_tuple.is_exhausted85def test_factory_decorator():86 '''Test the `LazyTuple.factory` decorator.'''87 @LazyTuple.factory(definitely_infinite=True)88 def count(*args, **kwargs):89 return itertools.count(*args, **kwargs)90 my_count = count()91 assert isinstance(my_count, LazyTuple)92 assert repr(my_count) == '<LazyTuple: (...)>'93 assert my_count.definitely_infinite94 assert my_count[:10] == tuple(range(10))95 assert len(my_count) == 096def test_finite_iterator():97 '''Test `LazyTuple` on a finite iterator.'''98 my_finite_iterator = iter(range(5))99 lazy_tuple = LazyTuple(my_finite_iterator)100 assert not lazy_tuple.is_exhausted101 assert list(itertools.islice(lazy_tuple, 0, 2)) == [0, 1]102 assert not lazy_tuple.is_exhausted103 assert repr(lazy_tuple) == '<LazyTuple: [0, 1]...>'104 second_to_last = lazy_tuple[-2]105 assert second_to_last == 3106 assert lazy_tuple.is_exhausted107 assert len(lazy_tuple) == lazy_tuple.known_length == \108 len(lazy_tuple.collected_data)109 assert repr(lazy_tuple) == '<LazyTuple: [0, 1, 2, 3, 4]>'110 assert LazyTuple(reversed(LazyTuple(reversed(lazy_tuple)))) == lazy_tuple111 assert 6 * lazy_tuple == 2 * lazy_tuple * 3 == lazy_tuple * 3 * 2 == \112 (0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4,113 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4)114 assert lazy_tuple + ('meow', 'frr') == (0, 1, 2, 3, 4, 'meow', 'frr')115 assert ('meow', 'frr') + lazy_tuple == ('meow', 'frr', 0, 1, 2, 3, 4)116 identical_lazy_tuple = LazyTuple(iter(range(5)))117 assert not identical_lazy_tuple.is_exhausted118 my_dict = {}119 my_dict[identical_lazy_tuple] = 'flugzeug'120 assert identical_lazy_tuple.is_exhausted121 assert my_dict[lazy_tuple] == 'flugzeug'122 assert len(my_dict) == 1123 assert lazy_tuple == identical_lazy_tuple124 my_dict[lazy_tuple] = 'lederhosen'125 assert my_dict[identical_lazy_tuple] == 'lederhosen'126 assert len(my_dict) == 1127def test_immutable_sequence():128 '''Test that `LazyTuple` is considered an immutable sequence.'''...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful