Cheuk Ting Ho
entry point to modify the test
generating test data
def encode(input_string):
count = 1
prev = ""
lst = []
for character in input_string:
if character != prev:
if prev:
entry = (prev, count)
lst.append(entry)
count = 1
prev = character
else:
count += 1
entry = (character, count)
lst.append(entry)
return lst
def decode(lst):
q = ""
for character, count in lst:
q += character * count
return q
from hypothesis import given
from hypothesis.strategies import text
@given(text())
def test_decode_inverts_encode(s):
assert decode(encode(s)) == s
But I hope you are still using typing 🙃
hypothesis write gzip
Just type in command line...
from re import compile, error
from hypothesis.extra import ghostwriter
ghostwriter.fuzz(compile, except_=error)
from typing import Sequence
from hypothesis.extra import ghostwriter
def timsort(seq: Sequence[int]) -> Sequence[int]:
return sorted(seq)
ghostwriter.idempotent(timsort)
import json
from hypothesis.extra import ghostwriter
ghostwriter.roundtrip(json.dumps, json.loads)
import math
from hypothesis.extra import ghostwriter
def my_pow(x, y):
result = 1.0
for _ in range(y):
result *= x
return result
ghostwriter.equivalent(my_pow, math.pow)
Let's try 😉