Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing verbose report format for nosetests

I am running my tests using nosetests in verbose mode:

....
test_cache_region (tests.test_sysutil.TestCachedMethodDecorator) ... ok
test_expire (tests.test_sysutil.TestCachedMethodDecorator) ... ok
test_lru (tests.test_sysutil.TestCachedMethodDecorator) ... ok
test_max_capacity (tests.test_sysutil.TestCachedMethodDecorator) ... ok
test_DecimalJSONEncoder (tests.test_util.UtilTestCase) ... ok
test_cdecimal_support (tests.test_util.UtilTestCase) ... ok
test_ceil_with_ndigits (tests.test_util.UtilTestCase) ... ok
test_switch_keyboard (tests.test_util.UtilTestCase) ... ok
...

Is there a way to easily change the report format to be like this:

...
tests.test_sysutil.TestCachedMethodDecorator.test_lru ... ok
tests.test_sysutil.TestCachedMethodDecorator.test_max_capacity ... ok
tests.test_util.UtilTestCase.test_DecimalJSONEncoder ... ok
tests.test_util.UtilTestCase.test_cdecimal_support ... ok
...
like image 790
warvariuc Avatar asked Dec 26 '22 21:12

warvariuc


1 Answers

You need to override the str method of your TestCase class in the following way:

def __str__(self):
    return __name__ + "." + self.__class__.__name__ + "." +  self._testMethodName

Modify the return string at your will.

like image 185
jorispilot Avatar answered Dec 28 '22 22:12

jorispilot