randomfactory is a helper function for generating random output that is used in testcase.
Project description
randomfactory
randomfactory is a helper function for generating random output that is used in testcase.
Installation
$ pip install randomfactory
randomfactory supports Python 3.8 and newer.
Usage
from randomfactory import *
# Generate a random integer between 0 and 100
test_int = generate_integer(0, 100)
print(test_int) # 42
# Generate a random alphabet
test_alphabet = generate_alphabet()
print(test_alphabet) # 'a'
# Generate a random string with length 10
test_string = generate_string(10)
print(test_string) # 'abcdefghij'
# Generate a random string with length 10 and only contains 'a', 'b', 'c'
test_string = generate_string(10, ['a', 'b', 'c'])
print(test_string) # 'abacacabba'
# Generate a random word
test_word = generate_word(10)
print(test_word) # 'abcdefghij'
# Generate an array
test_array = generate_array(10, 0, 100)
print(test_array) # [42, 42, 32, 23, 42, 42, 13, 42, 42, 42]
# Generate 2d array
test_2d_array = generate_2d_array(3, 2, 0, 100)
print(test_2d_array) # [[12, 42], [15, 22], [42, 31]]
# Generate an array that contains only unique elements
test_unique_array = generate_unique_array(4, 0, 100)
print(test_unique_array) # [42, 32, 23, 13]
# Generate a subset of an array
test_subset = generate_subseq([1, 2, 3, 4, 5], 3)
print(test_subset) # [1, 3, 4]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
randomfactory-1.0.8.tar.gz
(2.0 kB
view details)
Built Distribution
File details
Details for the file randomfactory-1.0.8.tar.gz
.
File metadata
- Download URL: randomfactory-1.0.8.tar.gz
- Upload date:
- Size: 2.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | db1340881e791e4ea3332d7f059fa45d8d73427a921f96629b35edb907de9353 |
|
MD5 | 4028f0eadc80de47dd8ca935bc7d8c22 |
|
BLAKE2b-256 | a21a6300c5908770d5ed0484c08e9fc460809c3f7a96b582698c1055fedc8a75 |
File details
Details for the file randomfactory-1.0.8-py3-none-any.whl
.
File metadata
- Download URL: randomfactory-1.0.8-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 287d34a61ad117e3a485aa9ffa76ce3b71b52b9a39dd3f62e640407266b6c5b5 |
|
MD5 | 81b1cacd92771fb37e20e3a4c6a296cc |
|
BLAKE2b-256 | 74d340903ee6ac7a55770b04d0b34cab2d2f2ac33c2e2dce341c2e06e7f7240d |