Unittest Frame work Nose Testing Framework - Unittest Framework

What is Nose Testing Framework?

The nose project changed into released in 2005, the yr after py.test received its modern guise. It was written by Jason Pellerin to support the equal test idioms that were pioneered by py.check, but in a package that is easier to install and keep.

The nose module can be installed with the help of pip utility


This will install the nose module in the present day Python distribution as well as a nosetest.exe, which means the test may be run using this application as well as using –m switch.

nose collects tests from unittest.TestCase subclasses, of course. We also can write easy test functions, as well as test training that are not subclasses of unittest.TestCase. nose also supplies some of helpful functions for writing timed tests, testing for exceptions, and other common use cases.

nose collects tests automatically. There’s no need to manually collect check cases into test suites. running tests is responsive, because nose begins running tests as soon as the first test module is loaded.

As with the unittest module, nose helps fixtures at the package, module, class, and test case level, so expensive initialization may be executed as on occasion as viable.

Basic usage

Let us consider nosetest.py similar to the script used earlier –

In order to run the above test, use the following command line syntax –

The output displayed on console will be as follows –

nose can be integrated with DocTest by using with-doctest option in athe bove command line.

You may use nose in a test script –

If you do not wish the test script to exit with 0 on success and 1 on failure (like unittest.main), use nose.run() instead –

The result will be true if the test run is a success, or false if it fails or raises an uncaught exception.

nose supports fixtures (setup and teardown methods) on the package deal, module, class, and test level. As with py.test or unittest fixtures, setup always runs before any test (or collection of tests for test packages and modules); teardown runs if setup has completed correctly, regardless of the status of the test run.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Unittest Framework Topics