useful tools for test development
Project description
ttoolly_utils
About
ttoolly_utils provides some useful tools for testing
Getting started
Installation
pip install ttoolly-utils
Usage Examples
1. Asserts
assert_status_code
from ttoolly_utils.asserts import assert_status_code
assert_status_code(404, 200)
# Output: AssertionError: Status code 404. Expected 200
assert_dict_equal
from ttoolly_utils.asserts import assert_dict_equal
d1 = {'a': 1, 'b': 2, 'c': 3}
d2 = {'b': 3, 'd': 4, 'c': {'c1': 2}}
assert_dict_equal(d1, d2)
# Output:
AssertionError: Not in first dict: ['d']
Not in second dict: ['a']
[b]: 2 != 3
[c]:
[c][c1]: 1 != 2
assert_list_equal
from ttoolly_utils.asserts import assert_list_equal
l1 = [1, 2, 3]
l2 = [1, 4, 3]
assert_list_equal(l1, l2)
# Output: AssertionError: [line 1]: 2 != 4
2. Randomizer
get_randname
from ttoolly_utils.randomizer import get_randname
print(get_randname(8, 'w')) # e.g. 'aBcDeFgH'
print(get_randname(10, 'd')) # e.g. '1234567890'
print(get_randname(5, 'p')) # e.g. ';@$..'
print(get_randname(5, 's')) # e.g. '\x0b\n \n'
print(get_randname()) # e.g. 'oNC<H%|`^\t
get_random_color
from ttoolly_utils.randomizer import get_random_color
print(get_random_color('rgb')) # e.g. 'rgb(123, 45, 67)'
print(get_random_color('hex')) # e.g. '#1a2b3c'
get_random_datetime_value
from ttoolly_utils.randomizer import get_random_datetime_value
print(get_random_datetime_value()) # e.g. '2025-06-15 12:34:56.123456'
get_random_domain_value
from ttoolly_utils.randomizer import get_random_domain_value
print(get_random_domain_value(10)) # e.g. 'tf.vl.PRSh'
get_random_email_value
from ttoolly_utils.randomizer import get_random_email_value
print(get_random_email_value(10)) # e.g. 'ae\\;1@c.xh'
print(get_random_email_value(10, safe=True)) # e.g. '30o@dr.lxr'
3. Utils
continue_on_fail
from ttoolly_utils.utils import continue_on_fail
errors = []
with continue_on_fail(errors, "Test block"):
assert 1 == 2, "Numbers do not match"
print(errors)
# Output: ['Test block\nTraceback (most recent call last): ... AssertionError: Numbers do not match']
convert_size_to_bytes
from ttoolly_utils.utils import convert_size_to_bytes
print(convert_size_to_bytes('2K')) # Output: 2048
print(convert_size_to_bytes('5M')) # Output: 5242880
get_all_subclasses
from ttoolly_utils.utils import get_all_subclasses
class A: pass
class B(A): pass
class C(B): pass
print(list(get_all_subclasses(A))) # Output: [<class '__main__.C'>, <class '__main__.B'>]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ttoolly_utils-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ttoolly_utils-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5933160d3de53e7f4066cade1b3269417f4a75b5fff43e055ce2fc326b3bd2f
|
|
| MD5 |
aa45f39082f3a84bf2a439127102b768
|
|
| BLAKE2b-256 |
e8e7e5329d9ff051f9f1f8f1995271e8a4fbb34e90d55d23b94b702ba340768f
|