Runs test code contained in strings
Project description
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
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
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 strtest-0.1.0.tar.gz.
File metadata
- Download URL: strtest-0.1.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f817f9703d4c0fb9f56a26c6ee7ebf32e42c39dbc3215121d95d80efa34fe915
|
|
| MD5 |
908b967eabfe22839343e35b5c43decb
|
|
| BLAKE2b-256 |
7a22060a6100ec67d0004862ff2132ff3547e3b546787d0788b4f76567e0e852
|
File details
Details for the file strtest-0.1.0-py3-none-any.whl.
File metadata
- Download URL: strtest-0.1.0-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d924cc1cf4fa0c4392824a85f9320279c62ff831cd5fdc66ce0ce33b8588f51
|
|
| MD5 |
1f5ac398e9b8af965e78543a24af85d8
|
|
| BLAKE2b-256 |
1df702adc7f35cc4119ec3d52ed814d2bcecfd4fa36c1956d5379ffb044957f8
|