0 votes
in Python by (4.5k points)
What all nose testing tools exist in Python?

1 Answer

0 votes
by (4.5k points)
nose contains few methods and tools useful for test automation, in nose.tools module.

nose has it's own assert method i.e assert_equals in nose.tools.

Usage of assert_equals is shown in below example by modifying definition of test_sample_nosetest in test_sample_module.py.

def test_sample_nose1test():


Usage of OK_ and EQ_

nose.tools also contain methods ok_ and eq_, which function similar to assert and assert_equals respectively.

You can optionally pass an error message that can be displayed when a test fails.

Usage of ok_ and eq_ is shown in below example by defining two functions in sample_test_module.py

from nose.tools import ok_, eq_

def test_using_ok():


def test_using_eq():

    eq_(2+3, 5)

Usage of 'raises' decorator

raises decorator is used to decorate those tests, which are expected to raise an Exception.

The test will be successful only if the exception raised is present in list of exceptions passed to raises decorator.

A sample test added to test_sample_module.py is shown below.

from nose.tools import raises


def test_using_raises():

    eq_(2+'3', 5)

Related questions