A simple test framework
Project description
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@test
decorator - 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
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 Distribution
TestIt-0.1.0.tar.gz
(4.7 kB
view hashes)
Built Distribution
TestIt-0.1.0-py3-none-any.whl
(4.8 kB
view hashes)