Skip to main content

A simple test framework

Project description


The Simple Testing Framework

How to use

Create a tests folder in your project root.


  • 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

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/

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for TestIt, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size TestIt-0.1.0-py3-none-any.whl (4.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size TestIt-0.1.0.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page