[issue11332] Increase logging/__init__.py coverage to 97%

Vinay Sajip report at bugs.python.org
Sun Feb 27 00:57:10 CET 2011


Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:

@Brett: I've no religious/dogmatic objection to mocking, either, so I agree with your comment. I merely observed that it's not generally implemented in the Python test suite (not that I've made an exhaustive study of it, so I'm open to being corrected on this point). Also, I don't see much value in some of the low-level tests in the patch. For example: logging.disable is defined as

def disable(level):
    """
    Disable all logging calls less severe than 'level'.
    """
    root.manager.disable = level

The test for it is:

    def test_disable(self):
        disableBackup = logging.root.manager.disable
        logging.disable(10)
        self.assertEqual(logging.root.manager.disable, 10)
        logging.root.manager.disable = disableBackup

which is really just testing at a low level - that the attribute was set - but not more usefully, at a higher level, the practical effect of the disable call.

I appreciate the value that tests bring, but I'm just being a bit wary of letting the tail wag the dog too much in the interests of higher coverage ;-) So, I suppose my test case preferences tend more towards an acceptance test style rather than a "pure" unit test style.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11332>
_______________________________________


More information about the Python-bugs-list mailing list