Skip to main content

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


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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

TestIt-0.1.0-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file TestIt-0.1.0.tar.gz.

File metadata

  • Download URL: TestIt-0.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for TestIt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 386fe3867f44eb01e97fee33cdd20efdb3cce6c5f33f731ae32c337a352eded3
MD5 573144e977ecb324dcf8c74f5b4dddc0
BLAKE2b-256 487bea58b7038eaf56bf91fbce53249144042ebb5bdf9ac23a1bd69c8124485b

See more details on using hashes here.

File details

Details for the file TestIt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: TestIt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for TestIt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0094281132d8def76daac4e323ab4e206e413b8e5f03a6d14142d93c94bc9c2
MD5 4726f2c9cc1dd121d465e6347e0928a5
BLAKE2b-256 f6122cb7380f1f41732162704c66c769df0f6191f1aa986cc920730d2f1b4bf1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page