Python String Test Runner
Unittest wrapper that runs tests contained in strings.
Setup
pip install strtest
Running tests
run_str_test.py [-f function_name] file_with_the_function.py test_file.py
There is an example here
Test files
Test files must contain a class called TestCase that inherits from str_test.TestCaseWrapper. All methods with names starting with test_ will be considered tests.
from strtest import str_test
class TestCase(str_test.TestCaseWrapper):
TIMEOUT = 1 # In seconds
def test_1(self):
result = self.function(1, 2)
self.assertEqual(3, result, msg=f'Results are not equal. Expected: 3. Got: {result}')
def test_2(self):
self.assertTrue(False, msg='This will always fail')
Example
Assume you have the test file all_tests.py with the code above and want to test the file my_implementation.py containing the following code:
def add_numbers(a, b):
return a + b
You can run the tests with:
run_str_test.py -f add_numbers my_implementation.py all_tests.py
Metadata
Release files for strtest 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strtest-0.1.0.tar.gz | 7.9 kB | Without provenance | Details for strtest-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strtest-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for strtest-0.1.0-py3-none-any.whl |
Total release size: 17.4 kB
Release files / strtest-0.1.0.tar.gz
| Download URL | strtest-0.1.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f817f9703d4c0fb9f56a26c6ee7ebf32e42c39dbc3215121d95d80efa34fe915
|
|
BLAKE2b-256 checksum How to use checksums |
7a22060a6100ec67d0004862ff2132ff3547e3b546787d0788b4f76567e0e852
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.1
|
Release files / strtest-0.1.0-py3-none-any.whl
| Download URL | strtest-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d924cc1cf4fa0c4392824a85f9320279c62ff831cd5fdc66ce0ce33b8588f51
|
|
BLAKE2b-256 checksum How to use checksums |
1df702adc7f35cc4119ec3d52ed814d2bcecfd4fa36c1956d5379ffb044957f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.1
|
Security for strtest 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.