Skip to content

Instantly share code, notes, and snippets.

@jkr
Last active November 15, 2016 15:22
Show Gist options
  • Save jkr/99c86b0a027182fe15ae277c3c352aba to your computer and use it in GitHub Desktop.
Save jkr/99c86b0a027182fe15ae277c3c352aba to your computer and use it in GitHub Desktop.
import string
import random
import subprocess as sp
import re
def generate_thingy(x, y, z):
txt = ''.join(random.choice(string.ascii_lowercase) for i in range(x))
lab = ''.join(random.choice(string.ascii_lowercase) for i in range(y))
sep = ''.join(random.choice(string.ascii_lowercase + string.punctuation) for i in range(z))
return bytes("[%s]{.%s}%s _hi_" % (txt, lab,sep), encoding='utf-8')
def get_output(x, y, z):
txt = generate_thingy(x,y,z)
pipe = sp.Popen(["pandoc"], stdin=sp.PIPE, stdout=sp.PIPE)
(stdout, err) = pipe.communicate(txt)
return (x, y, z, txt, stdout)
def unemphasized(tup):
(m,n,o,inp,outp) = tup
return re.match(r'.*<em>hi</em></p>\n$', outp.decode('utf-8')) is None
def rand_test(n):
for i in range(n):
x = random.randint(1,30)
y = random.randint(1,30)
z = random.randint(0,5)
out = get_output(x,y,z)
if unemphasized(out):
yield out
if __name__ == '__main__':
tests = 50000
for tup in rand_test(tests):
(txt_len, class_len, sep_len, inp, outp) = tup
inp_str = inp.decode('utf-8')
if sep_len==0:
sep = ""
else:
sep = inp_str.split('}',1)[1].split()[0]
print ('%d\t%d\t%d\t%s\t%s' % (txt_len, class_len, sep_len, sep, inp_str))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment