Skip to content

Instantly share code, notes, and snippets.

@DevanR
Created December 12, 2017 16:05
Show Gist options
  • Save DevanR/8aba3ae9c97398ca57f3c9dd9b749c6e to your computer and use it in GitHub Desktop.
Save DevanR/8aba3ae9c97398ca57f3c9dd9b749c6e to your computer and use it in GitHub Desktop.
Function to generate random strings
def generate_random_string(chars=string.ascii_uppercase + string.digits):
"""
Generates a random string for input testing.
Ref: https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python
"""
size=random.randint(1, 10)
return ''.join(random.choice(chars) for _ in range(size))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment