TestIt
The Simple Testing Framework
How to use
Create a tests folder in your project root.
Organization
- Each Python file in
tests - Each function that start with
test_and has the@testdecorator - Each individul test in the function
A basic test
Project code in main.py
def fib(n):
a, b = 0, 1
if n <= 2:
return n
for _ in range(2, n+1):
a, b = b, a+b
return b
In tests/foo.py
from testit import test, Test
@test('test that the output of fibonacci sequence is accurate')
def test_accurate(t: 'Test'):
t.expect(fib, 1).equal(1).message('fib of 1 should be 1')
t.expect(fib, 5).equal(5).message('fib of 5 should be 5')
t.expect(fib, 10).equal(55).message('fib of 10 should be 55')
@test('test that the wrong numbers dont work')
def test_wrong(t: 'Test'):
t.expect(fib, 2).not_equal(3).message('fib of 2 should not be 2')
t.expect(fib, 10).not_equal(55).message('fib of 10 should not be 55')
Output after running python -m testit
PASS test_accurate - test that the output of fibonacci sequence is accurate ✓ fib of 1 should be 1 ✓ fib of 5 should be 5 ✓ fib of 10 should be 55 FAIL test_wrong - test that the wrong numbers dont work ✓ fib of 2 should not be 2 ✗ fib of 10 should not be 55 - Expected: fib(10) != 55 + Recieved value: 55
Metadata
Release files for TestIt 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 | |
|---|---|---|---|
| TestIt-0.1.0.tar.gz | 4.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| TestIt-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / TestIt-0.1.0.tar.gz
| Download URL | TestIt-0.1.0.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
386fe3867f44eb01e97fee33cdd20efdb3cce6c5f33f731ae32c337a352eded3
|
|
BLAKE2b-256 checksum How to use checksums |
487bea58b7038eaf56bf91fbce53249144042ebb5bdf9ac23a1bd69c8124485b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
|
Release files / TestIt-0.1.0-py3-none-any.whl
| Download URL | TestIt-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e0094281132d8def76daac4e323ab4e206e413b8e5f03a6d14142d93c94bc9c2
|
|
BLAKE2b-256 checksum How to use checksums |
f6122cb7380f1f41732162704c66c769df0f6191f1aa986cc920730d2f1b4bf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10
|