A simple unit testing framework for Python 3.
Project description
VSUT is a simple unit test framework for Python.
Usage
A unit can be described , like follows:
...
class UnitTest(vsut.unit.Unit):
def testComponentOne(self):
...
def testComponentTwo(self):
...
Any methods that start with ‘test’ will be executed automatically, once the case is run.
Asserts & Fail Conditions
The following methods can be used in a test-case to check for success or failure:
assertEqual(expected, actual) - Checks for equality of the two arguments.
assertNotEqual(expected, actual) - Checks for inequality of the two arguments.
assertTrue(expected) - Checks whether the argument is the boolean value True.
assertFalse(expected) - Checks whether the argument is the boolean value False.
assertIn(expected, collection) - Checks whether the argument is in the collection.
assertNotIn(expected, collection) - Checks whether the argument is not in the collection.
assertIs(expected, actual) - Checks whether the value is the expected.
assertIsNot(expected, actual) - Checks whether the value is not the expected.
assertIsNone(expected) - Checks whether the argument is None.
assertIsNotNone(expected) - Checks whether the argument is not None.
assertRaises(exception, func, *args) - Checks whether the function ‘func’ raises an exception of the type ‘exception’.
For any of these methods a message parameter can be specified, that will be printed instead of the default message.
Example
...
assertEqual(True, False, message="True is not False")
...
Full Example
from vsut.unit import Unit
from vsut.assertion import assertEqual
class TestCase(Unit):
def testExample(self):
a = True
b = True
c = False
assertEqual(a, b)
assertEqual(b, c)
Running units
Units can be run with the test runner, as follows:
python runner.py [--format=table] module.TestClass module1.TestClass1 ...
NOTE: Some characters require escaping with \, as they are special characters.
Output as Table
#### Output as CSV Output as CSV can look like this for example:
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
File details
Details for the file vsut-1.5.4.tar.gz.
File metadata
- Download URL: vsut-1.5.4.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7595ea06591758531a86a01fa1a2592ca68200b628fb0cbfa99085144721de44
|
|
| MD5 |
f2b65d77c02b85126c3474c63c51bca9
|
|
| BLAKE2b-256 |
f98c285ce16912c71b90748563c64ed6eacd6768338d8d2e403682a5c986d95e
|