Change the detailed report format for media

I run 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 change the report format in this way:

 ... 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 ... 
+4
source share
2 answers

You need to override the str method of your TestCase class as follows:

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

Change the returned string as you wish.

+5
source

As jorispilot suggested, you can change every test system in your project. Alternatively, you can change the behavior of the nose by creating a Nose plugin that implements the description. See fooobar.com/questions/673287 / ... for the exact recipe to achieve your goal.

+5
source

Source: https://habr.com/ru/post/1499086/


All Articles