How to use mark_interesting method in hypothesis

Best Python code snippet using hypothesis

test_shrinker.py

Source:test_shrinker.py Github

copy

Full Screen

...32 def shrinker(data):33 n = data.draw_bits(4)34 b = [data.draw_bits(8) for _ in range(n)]35 if any(b):36 data.mark_interesting()37 shrinker.fixate_shrink_passes(["minimize_individual_blocks"])38 assert list(shrinker.shrink_target.buffer) == [1, 1]39def test_deletion_and_lowering_fails_to_shrink(monkeypatch):40 monkeypatch.setattr(41 Shrinker,42 "shrink",43 lambda self: self.fixate_shrink_passes(["minimize_individual_blocks"]),44 )45 def gen(self):46 self.cached_test_function(10)47 monkeypatch.setattr(ConjectureRunner, "generate_new_examples", gen)48 @run_to_buffer49 def x(data):50 for _ in range(10):51 data.draw_bytes(1)52 data.mark_interesting()53 assert x == bytes(10)54def test_duplicate_blocks_that_go_away():55 @shrinking_from([1, 1, 1, 2] * 2 + [5] * 2)56 def shrinker(data):57 x = data.draw_bits(32)58 y = data.draw_bits(32)59 if x != y:60 data.mark_invalid()61 b = [data.draw_bytes(1) for _ in range(x & 255)]62 if len(set(b)) <= 1:63 data.mark_interesting()64 shrinker.fixate_shrink_passes(["minimize_duplicated_blocks"])65 assert shrinker.shrink_target.buffer == bytes(8)66def test_accidental_duplication(monkeypatch):67 @shrinking_from([18] * 20)68 def shrinker(data):69 x = data.draw_bits(8)70 y = data.draw_bits(8)71 if x != y:72 data.mark_invalid()73 if x < 5:74 data.mark_invalid()75 b = [data.draw_bytes(1) for _ in range(x)]76 if len(set(b)) == 1:77 data.mark_interesting()78 shrinker.fixate_shrink_passes(["minimize_duplicated_blocks"])79 assert list(shrinker.buffer) == [5] * 780def test_can_zero_subintervals(monkeypatch):81 @shrinking_from(bytes([3, 0, 0, 0, 1]) * 10)82 def shrinker(data):83 for _ in range(10):84 data.start_example(SOME_LABEL)85 n = data.draw_bits(8)86 data.draw_bytes(n)87 data.stop_example()88 if data.draw_bits(8) != 1:89 return90 data.mark_interesting()91 shrinker.shrink()92 assert list(shrinker.buffer) == [0, 1] * 1093def test_can_pass_to_an_indirect_descendant(monkeypatch):94 def tree(data):95 data.start_example(1)96 n = data.draw_bits(1)97 label = data.draw_bits(8)98 if n:99 tree(data)100 tree(data)101 data.stop_example(1)102 return label103 initial = bytes([1, 10, 0, 0, 1, 0, 0, 10, 0, 0])104 target = bytes([0, 10])105 good = {initial, target}106 @shrinking_from(initial)107 def shrinker(data):108 tree(data)109 if bytes(data.buffer) in good:110 data.mark_interesting()111 shrinker.fixate_shrink_passes(["pass_to_descendant"])112 assert shrinker.shrink_target.buffer == target113def shrink(buffer, *passes):114 def accept(f):115 shrinker = shrinking_from(buffer)(f)116 shrinker.fixate_shrink_passes(passes)117 return list(shrinker.buffer)118 return accept119def test_shrinking_blocks_from_common_offset():120 @shrinking_from([11, 10])121 def shrinker(data):122 m = data.draw_bits(8)123 n = data.draw_bits(8)124 if abs(m - n) <= 1 and max(m, n) > 0:125 data.mark_interesting()126 shrinker.mark_changed(0)127 shrinker.mark_changed(1)128 shrinker.lower_common_block_offset()129 x = shrinker.shrink_target.buffer130 assert sorted(x) == [0, 1]131def test_handle_empty_draws():132 @run_to_buffer133 def x(data):134 while True:135 data.start_example(SOME_LABEL)136 n = data.draw_bits(1)137 data.start_example(SOME_LABEL)138 data.stop_example()139 data.stop_example(discard=n > 0)140 if not n:141 break142 data.mark_interesting()143 assert x == bytes([0])144def test_can_reorder_examples():145 @shrinking_from([1, 0, 1, 1, 0, 1, 0, 0, 0])146 def shrinker(data):147 total = 0148 for _ in range(5):149 data.start_example(0)150 if data.draw_bits(8):151 total += data.draw_bits(9)152 data.stop_example(0)153 if total == 2:154 data.mark_interesting()155 shrinker.fixate_shrink_passes(["reorder_examples"])156 assert list(shrinker.buffer) == [0, 0, 0, 1, 0, 1, 1, 0, 1]157def test_permits_but_ignores_raising_order(monkeypatch):158 monkeypatch.setattr(159 ConjectureRunner,160 "generate_new_examples",161 lambda runner: runner.cached_test_function([1]),162 )163 monkeypatch.setattr(164 Shrinker, "shrink", lambda self: self.incorporate_new_buffer(bytes([2]))165 )166 @run_to_buffer167 def x(data):168 data.draw_bits(2)169 data.mark_interesting()170 assert list(x) == [1]171def test_block_deletion_can_delete_short_ranges(monkeypatch):172 @shrinking_from([v for i in range(5) for _ in range(i + 1) for v in [0, i]])173 def shrinker(data):174 while True:175 n = data.draw_bits(16)176 for _ in range(n):177 if data.draw_bits(16) != n:178 data.mark_invalid()179 if n == 4:180 data.mark_interesting()181 shrinker.fixate_shrink_passes([block_program("X" * i) for i in range(1, 5)])182 assert list(shrinker.shrink_target.buffer) == [0, 4] * 5183def test_try_shrinking_blocks_ignores_overrun_blocks(monkeypatch):184 monkeypatch.setattr(185 ConjectureRunner,186 "generate_new_examples",187 lambda runner: runner.cached_test_function([3, 3, 0, 1]),188 )189 monkeypatch.setattr(190 Shrinker,191 "shrink",192 lambda self: self.try_shrinking_blocks((0, 1, 5), bytes([2])),193 )194 @run_to_buffer195 def x(data):196 n1 = data.draw_bits(8)197 data.draw_bits(8)198 if n1 == 3:199 data.draw_bits(8)200 k = data.draw_bits(8)201 if k == 1:202 data.mark_interesting()203 assert list(x) == [2, 2, 1]204def test_dependent_block_pairs_is_up_to_shrinking_integers():205 # Unit test extracted from a failure in tests/nocover/test_integers.py206 distribution = Sampler([4.0, 8.0, 1.0, 1.0, 0.5])207 sizes = [8, 16, 32, 64, 128]208 @shrinking_from(b"\x03\x01\x00\x00\x00\x00\x00\x01\x00\x02\x01")209 def shrinker(data):210 size = sizes[distribution.sample(data)]211 result = data.draw_bits(size)212 sign = (-1) ** (result & 1)213 result = (result >> 1) * sign214 cap = data.draw_bits(8)215 if result >= 32768 and cap == 1:216 data.mark_interesting()217 shrinker.fixate_shrink_passes(["minimize_individual_blocks"])218 assert list(shrinker.shrink_target.buffer) == [1, 1, 0, 1, 0, 0, 1]219def test_finding_a_minimal_balanced_binary_tree():220 # Tests iteration while the shape of the thing being iterated over can221 # change. In particular the current example can go from trivial to non222 # trivial.223 def tree(data):224 # Returns height of a binary tree and whether it is height balanced.225 data.start_example("tree")226 n = data.draw_bits(1)227 if n == 0:228 result = (1, True)229 else:230 h1, b1 = tree(data)231 h2, b2 = tree(data)232 result = (1 + max(h1, h2), b1 and b2 and abs(h1 - h2) <= 1)233 data.stop_example("tree")234 return result235 # Starting from an unbalanced tree of depth six236 @shrinking_from([1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0])237 def shrinker(data):238 _, b = tree(data)239 if not b:240 data.mark_interesting()241 shrinker.shrink()242 assert list(shrinker.shrink_target.buffer) == [1, 0, 1, 0, 1, 0, 0]243def test_float_shrink_can_run_when_canonicalisation_does_not_work(monkeypatch):244 # This should be an error when called245 monkeypatch.setattr(Float, "shrink", None)246 base_buf = int_to_bytes(flt.base_float_to_lex(1000.0), 8) + bytes(1)247 @shrinking_from(base_buf)248 def shrinker(data):249 flt.draw_float(data)250 if bytes(data.buffer) == base_buf:251 data.mark_interesting()252 shrinker.fixate_shrink_passes(["minimize_floats"])253 assert shrinker.shrink_target.buffer == base_buf254def test_try_shrinking_blocks_out_of_bounds():255 @shrinking_from(bytes([1]))256 def shrinker(data):257 data.draw_bits(1)258 data.mark_interesting()259 assert not shrinker.try_shrinking_blocks((1,), bytes([1]))260def test_block_programs_are_adaptive():261 @shrinking_from(bytes(1000) + bytes([1]))262 def shrinker(data):263 while not data.draw_bits(1):264 pass265 data.mark_interesting()266 p = shrinker.add_new_pass(block_program("X"))267 shrinker.fixate_shrink_passes([p.name])268 assert len(shrinker.shrink_target.buffer) == 1269 assert shrinker.calls <= 60270def test_zero_examples_with_variable_min_size():271 @shrinking_from(bytes([255]) * 100)272 def shrinker(data):273 any_nonzero = False274 for i in range(1, 10):275 any_nonzero |= data.draw_bits(i * 8) > 0276 if not any_nonzero:277 data.mark_invalid()278 data.mark_interesting()279 shrinker.shrink()280 assert len([d for d in shrinker.shrink_target.blocks if not d.all_zero]) == 1281def test_zero_contained_examples():282 @shrinking_from(bytes([1]) * 8)283 def shrinker(data):284 for _ in range(4):285 data.start_example(1)286 if data.draw_bits(8) == 0:287 data.mark_invalid()288 data.start_example(1)289 data.draw_bits(8)290 data.stop_example()291 data.stop_example()292 data.mark_interesting()293 shrinker.shrink()294 assert list(shrinker.shrink_target.buffer) == [1, 0] * 4295def test_zig_zags_quickly():296 @shrinking_from(bytes([255]) * 4)297 def shrinker(data):298 m = data.draw_bits(16)299 n = data.draw_bits(16)300 if m == 0 or n == 0:301 data.mark_invalid()302 if abs(m - n) <= 1:303 data.mark_interesting(0)304 # Two different interesting origins for avoiding slipping in the305 # shrinker.306 if abs(m - n) <= 10:307 data.mark_interesting(1)308 shrinker.fixate_shrink_passes(["minimize_individual_blocks"])309 assert shrinker.engine.valid_examples <= 100310 assert list(shrinker.shrink_target.buffer) == [0, 1, 0, 1]311def test_zero_irregular_examples():312 @shrinking_from([255] * 6)313 def shrinker(data):314 data.start_example(1)315 data.draw_bits(8)316 data.draw_bits(16)317 data.stop_example()318 data.start_example(1)319 interesting = data.draw_bits(8) > 0 and data.draw_bits(16) > 0320 data.stop_example()321 if interesting:322 data.mark_interesting()323 shrinker.shrink()324 assert list(shrinker.shrink_target.buffer) == [0] * 3 + [1, 0, 1]325def test_retain_end_of_buffer():326 @shrinking_from([1, 2, 3, 4, 5, 6, 0])327 def shrinker(data):328 interesting = False329 while True:330 n = data.draw_bits(8)331 if n == 6:332 interesting = True333 if n == 0:334 break335 if interesting:336 data.mark_interesting()337 shrinker.shrink()338 assert list(shrinker.buffer) == [6, 0]339def test_can_expand_zeroed_region():340 @shrinking_from([255] * 5)341 def shrinker(data):342 seen_non_zero = False343 for _ in range(5):344 if data.draw_bits(8) == 0:345 if seen_non_zero:346 data.mark_invalid()347 else:348 seen_non_zero = True349 data.mark_interesting()350 shrinker.shrink()351 assert list(shrinker.shrink_target.buffer) == [0] * 5352def test_can_expand_deleted_region():353 @shrinking_from([1, 2, 3, 4, 0, 0])354 def shrinker(data):355 def t():356 data.start_example(1)357 data.start_example(1)358 m = data.draw_bits(8)359 data.stop_example()360 data.start_example(1)361 n = data.draw_bits(8)362 data.stop_example()363 data.stop_example()364 return (m, n)365 v1 = t()366 if v1 == (1, 2):367 if t() != (3, 4):368 data.mark_invalid()369 if v1 == (0, 0) or t() == (0, 0):370 data.mark_interesting()371 shrinker.shrink()372 assert list(shrinker.buffer) == [0, 0]373def test_shrink_pass_method_is_idempotent():374 @shrinking_from([255])375 def shrinker(data):376 data.draw_bits(8)377 data.mark_interesting()378 sp = shrinker.shrink_pass(block_program("X"))379 assert isinstance(sp, ShrinkPass)380 assert shrinker.shrink_pass(sp) is sp381def test_will_terminate_stalled_shrinks():382 # Suppress the time based slow shrinking check - we only want383 # the one that checks if we're in a stall where we've shrunk384 # as far as we're going to get.385 time.freeze()386 @shrinking_from([255] * 100)387 def shrinker(data):388 count = 0389 for _ in range(100):390 if data.draw_bits(8) != 255:391 count += 1392 if count >= 10:393 return394 data.mark_interesting()395 shrinker.shrink()396 assert shrinker.calls <= 1 + 2 * shrinker.max_stall397def test_will_let_fixate_shrink_passes_do_a_full_run_through():398 @shrinking_from(range(50))399 def shrinker(data):400 for i in range(50):401 if data.draw_bits(8) != i:402 data.mark_invalid()403 data.mark_interesting()404 shrinker.max_stall = 5405 passes = [block_program("X" * i) for i in range(1, 11)]406 with pytest.raises(StopShrinking):407 shrinker.fixate_shrink_passes(passes)408 assert shrinker.shrink_pass(passes[-1]).calls > 0409@pytest.mark.parametrize("n_gap", [0, 1, 2, 3])410def test_can_simultaneously_lower_non_duplicated_nearby_blocks(n_gap):411 @shrinking_from([1, 1] + [0] * n_gap + [0, 2])412 def shrinker(data):413 # Block off lowering the whole buffer414 if data.draw_bits(1) == 0:415 data.mark_invalid()416 m = data.draw_bits(8)417 for _ in range(n_gap):418 data.draw_bits(8)419 n = data.draw_bits(16)420 if n == m + 1:421 data.mark_interesting()422 shrinker.fixate_shrink_passes(["lower_blocks_together"])...

Full Screen

Full Screen

test_conjecture_engine.py

Source:test_conjecture_engine.py Github

copy

Full Screen

...37def test_can_index_results():38 @run_to_buffer39 def f(data):40 data.draw_bytes(5)41 data.mark_interesting()42 assert f.index(0) == 043 assert f.count(0) == 544def test_non_cloneable_intervals():45 @run_to_buffer46 def x(data):47 data.draw_bytes(10)48 data.draw_bytes(9)49 data.mark_interesting()50 assert x == hbytes(19)51def test_duplicate_buffers():52 @run_to_buffer53 def x(data):54 t = data.draw_bytes(10)55 if not any(t):56 data.mark_invalid()57 s = data.draw_bytes(10)58 if s == t:59 data.mark_interesting()60 assert x == bytes_from_list([0] * 9 + [1]) * 261def test_clone_into_variable_draws():62 @run_to_buffer63 def x(data):64 small = 065 large = 066 for _ in range(30):67 data.start_example()68 b = data.draw_bytes(1)[0] & 169 if b:70 data.draw_bytes(3)71 large += 172 else:73 data.draw_bytes(2)74 small += 175 data.stop_example()76 if small < 10:77 data.mark_invalid()78 if large >= 10:79 data.mark_interesting()80 assert set(x) == set((0, 1))81 assert x.count(1) == 1082 assert len(x) == 30 + (20 * 2) + (10 * 3)83def test_deletable_draws():84 @run_to_buffer85 def x(data):86 while True:87 x = data.draw_bytes(2)88 if x[0] == 255:89 data.mark_interesting()90 assert x == hbytes([255, 0])91def zero_dist(random, n):92 return hbytes(n)93def test_distribution_may_be_ignored():94 @run_to_buffer95 def x(data):96 t = data.draw_bytes(5, zero_dist)97 if all(t) and 255 in t:98 data.mark_interesting()99 assert x == hbytes([1] * 4 + [255])100def test_can_load_data_from_a_corpus():101 key = b'hi there'102 db = ExampleDatabase()103 value = b'=\xc3\xe4l\x81\xe1\xc2H\xc9\xfb\x1a\xb6bM\xa8\x7f'104 db.save(key, value)105 def f(data):106 if data.draw_bytes(len(value)) == value:107 data.mark_interesting()108 runner = TestRunner(109 f, settings=settings(database=db), database_key=key)110 runner.run()111 assert runner.last_data.status == Status.INTERESTING112 assert runner.last_data.buffer == value113 assert len(list(db.fetch(key))) == 1114def test_terminates_shrinks():115 shrinks = [-1]116 def tf(data):117 x = hbytes(data.draw_bytes(100))118 if sum(x) >= 500:119 shrinks[0] += 1120 data.mark_interesting()121 runner = TestRunner(tf, settings=settings(122 max_examples=5000, max_iterations=10000, max_shrinks=10,123 database=None,124 ))125 runner.run()126 assert runner.last_data.status == Status.INTERESTING127 # There's an extra non-shrinking check step to abort in the presence of128 # flakiness129 assert shrinks[0] == 11130def test_detects_flakiness():131 failed_once = [False]132 count = [0]133 def tf(data):134 data.draw_bytes(1)135 count[0] += 1136 if not failed_once[0]:137 failed_once[0] = True138 data.mark_interesting()139 runner = TestRunner(tf)140 runner.run()141 assert count == [2]142def test_variadic_draw():143 def draw_list(data):144 result = []145 while True:146 data.start_example()147 d = data.draw_bytes(1)[0] & 7148 if d:149 result.append(data.draw_bytes(d))150 data.stop_example()151 if not d:152 break153 return result154 @run_to_buffer155 def b(data):156 if any(all(d) for d in draw_list(data)):157 data.mark_interesting()158 l = draw_list(TestData.for_buffer(b))159 assert len(l) == 1160 assert len(l[0]) == 1161def test_draw_to_overrun():162 @run_to_buffer163 def x(data):164 d = (data.draw_bytes(1)[0] - 8) & 0xff165 data.draw_bytes(128 * d)166 if d >= 2:167 data.mark_interesting()168 assert x == hbytes([10]) + hbytes(128 * 2)169def test_can_navigate_to_a_valid_example():170 def f(data):171 i = int_from_bytes(data.draw_bytes(2))172 data.draw_bytes(i)173 data.mark_interesting()174 runner = TestRunner(f, settings=settings(175 max_examples=5000, max_iterations=10000,176 buffer_size=2,177 database=None,178 ))179 runner.run()180 assert runner.last_data.status == Status.INTERESTING181 return hbytes(runner.last_data.buffer)182def test_stops_after_max_iterations_when_generating():183 key = b'key'184 value = b'rubber baby buggy bumpers'185 max_iterations = 100186 db = ExampleDatabase(':memory:')187 db.save(key, value)188 seen = []189 def f(data):190 seen.append(data.draw_bytes(len(value)))191 data.mark_invalid()192 runner = TestRunner(f, settings=settings(193 max_examples=1, max_iterations=max_iterations,194 database=db,195 ), database_key=key)196 runner.run()197 assert len(seen) == max_iterations198 assert value in seen199def test_stops_after_max_iterations_when_reading():200 key = b'key'201 max_iterations = 1202 db = ExampleDatabase(':memory:')203 for i in range(10):204 db.save(key, hbytes([i]))205 seen = []206 def f(data):207 seen.append(data.draw_bytes(1))208 data.mark_invalid()209 runner = TestRunner(f, settings=settings(210 max_examples=1, max_iterations=max_iterations,211 database=db,212 ), database_key=key)213 runner.run()214 assert len(seen) == max_iterations215def test_stops_after_max_examples_when_reading():216 key = b'key'217 db = ExampleDatabase(':memory:')218 for i in range(10):219 db.save(key, hbytes([i]))220 seen = []221 def f(data):222 seen.append(data.draw_bytes(1))223 runner = TestRunner(f, settings=settings(224 max_examples=1,225 database=db,226 ), database_key=key)227 runner.run()228 assert len(seen) == 1229def test_stops_after_max_examples_when_generating():230 seen = []231 def f(data):232 seen.append(data.draw_bytes(1))233 runner = TestRunner(f, settings=settings(234 max_examples=1,235 database=None,236 ))237 runner.run()238 assert len(seen) == 1239@given(st.random_module())240@settings(max_shrinks=0, timeout=3, min_satisfying_examples=1)241def test_interleaving_engines(rnd):242 @run_to_buffer243 def x(data):244 rnd = Random(hbytes(data.draw_bytes(8)))245 def g(d2):246 while True:247 b = d2.draw_bytes(1)[0]248 result = data.draw_bytes(b)249 if 255 in result:250 d2.mark_interesting()251 if 0 in result:252 d2.mark_invalid()253 runner = TestRunner(g, random=rnd)254 runner.run()255 if runner.last_data.status == Status.INTERESTING:256 data.mark_interesting()257 assert x[8:].count(255) == 1258def test_run_with_timeout_while_shrinking():259 def f(data):260 time.sleep(0.1)261 x = data.draw_bytes(32)262 if any(x):263 data.mark_interesting()264 runner = TestRunner(f, settings=settings(database=None, timeout=0.2,))265 start = time.time()266 runner.run()267 assert time.time() <= start + 1268 assert runner.last_data.status == Status.INTERESTING269def test_run_with_timeout_while_boring():270 def f(data):271 time.sleep(0.1)272 runner = TestRunner(f, settings=settings(database=None, timeout=0.2,))273 start = time.time()274 runner.run()275 assert time.time() <= start + 1276 assert runner.last_data.status == Status.VALID277def test_max_shrinks_can_disable_shrinking():278 seen = set()279 def f(data):280 seen.add(hbytes(data.draw_bytes(32)))281 data.mark_interesting()282 runner = TestRunner(f, settings=settings(database=None, max_shrinks=0,))283 runner.run()284 assert len(seen) == 1285def test_phases_can_disable_shrinking():286 seen = set()287 def f(data):288 seen.add(hbytes(data.draw_bytes(32)))289 data.mark_interesting()290 runner = TestRunner(f, settings=settings(291 database=None, phases=(Phase.reuse, Phase.generate),292 ))293 runner.run()294 assert len(seen) == 1295def test_saves_data_while_shrinking():296 key = b'hi there'297 n = 5298 db = ExampleDatabase(':memory:')299 assert list(db.fetch(key)) == []300 seen = set()301 def f(data):302 x = data.draw_bytes(512)303 if sum(x) >= 5000 and len(seen) < n:304 seen.add(hbytes(x))305 if hbytes(x) in seen:306 data.mark_interesting()307 runner = TestRunner(308 f, settings=settings(database=db), database_key=key)309 runner.run()310 assert runner.last_data.status == Status.INTERESTING311 assert len(seen) == n312 in_db = set(db.fetch(key))313 assert in_db.issubset(seen)314 assert in_db == seen315def test_can_discard():316 n = 32317 @run_to_buffer318 def x(data):319 seen = set()320 while len(seen) < n:321 seen.add(hbytes(data.draw_bytes(1)))322 data.mark_interesting()323 assert len(x) == n324def test_erratic_draws():325 n = [0]326 @run_to_buffer327 def x(data):328 data.draw_bytes(n[0])329 data.draw_bytes(255 - n[0])330 if n[0] == 255:331 data.mark_interesting()332 else:333 n[0] += 1334def test_no_read_no_shrink():335 count = [0]336 @run_to_buffer337 def x(data):338 count[0] += 1339 data.mark_interesting()340 assert x == b''341 assert count == [1]342def test_garbage_collects_the_database():343 key = b'hi there'344 n = 200345 db = ExampleDatabase(':memory:')346 assert list(db.fetch(key)) == []347 seen = set()348 go = True349 def f(data):350 x = hbytes(data.draw_bytes(512))351 if not go:352 return353 if sum(x) >= 5000 and len(seen) < n:354 seen.add(x)355 if x in seen:356 data.mark_interesting()357 runner = TestRunner(358 f, settings=settings(database=db, max_shrinks=2 * n), database_key=key)359 runner.run()360 assert runner.last_data.status == Status.INTERESTING361 assert len(seen) == n362 assert set(db.fetch(key)) == seen363 go = False364 runner = TestRunner(365 f, settings=settings(database=db, max_shrinks=2 * n), database_key=key)366 runner.run()367 assert 0 < len(set(db.fetch(key))) < n368def test_variable_replacement():369 @run_to_buffer370 def x(data):371 for _ in range(5):372 data.start_example()373 c = 0374 while True:375 d = data.draw_bytes(1)[0]376 if not d:377 break378 c += d379 data.stop_example()380 if c < 1000:381 data.mark_invalid()382 data.mark_interesting()383 assert x == x[:x.index(0) + 1] * 5384@given(st.randoms(), st.random_module())385def test_maliciously_bad_generator(rnd, seed):386 rnd = Random()387 @run_to_buffer388 def x(data):389 for _ in range(rnd.randint(0, 100)):390 data.draw_bytes(rnd.randint(0, 10))391 if rnd.randint(0, 1):392 data.mark_invalid()393 else:...

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