Ref. from : https://pymotw.com/2/unittest/
unittest is a testing framework for Python. It supports :
1. Test automation
2. Sharing of setup and shutdown code for tests
3. Aggregation of tests into collections
4. Independence of tests from the reporting framework
To implement the above mentioned functionalities, it supports some OOP based concepts:
- test fixture : It is something like initializing and loading all variables(everything needed) before running the real logic for testing.
- test case : Here we generally hard code responses for particular critical test cases.
- test suite : It’s a collection of various test cases and test suites.
- test runner : It decides the execution order during testing, interface for the user and format of output to be generated after the testing is completed.
- Without third party tools : Using C and C++
- With third party tools:
Extending Python with C or C++:
- Programming in C
- Basic knowledge of Python
Functions performed by extension modules in C and C++:
- Implement new built-in object types
- Can call C library functions and system calls
All user visible entities are defined by “Python.h” have prefix Py or PY. “Python.h” imports stdio.h, string.h, errno.h and stdlib.h automatically.
static PyObject * spam_system( PyObject * self, PyObject * args )
const char * command;
if(!PyArg_ParseTuple(args, "s", &command))
sts = system(command)
Here PyArg_ParseTuple() <-- checks the argument types and converts them to C values.
It returns True if arguments are of right type (nonzero), otherwise return False(zero)
if arguments list is invalid.