mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
Mock 100% coverage (GH-13045)
This was achieved by: * moving many pass statements in tests onto their own lines, so they pass line coverage and can match an easy ignore pattern if branch coverage is added later. * removing code that cannot be reached. * removing long-disabled tests. * removing unused code. * adding tests for uncovered code It turned out that removing `if __name__ == '__main__'` blocks that run unittest.main() at the bottom of test files was surprisingly contentious, so they remain and can be filtered out with an appropriate .coveragerc.
This commit is contained in:
parent
b7378d7728
commit
adbf178e49
9 changed files with 263 additions and 317 deletions
|
@ -305,8 +305,7 @@ class TestMockingMagicMethods(unittest.TestCase):
|
|||
|
||||
def test_magic_methods_and_spec(self):
|
||||
class Iterable(object):
|
||||
def __iter__(self):
|
||||
pass
|
||||
def __iter__(self): pass
|
||||
|
||||
mock = Mock(spec=Iterable)
|
||||
self.assertRaises(AttributeError, lambda: mock.__iter__)
|
||||
|
@ -330,8 +329,7 @@ class TestMockingMagicMethods(unittest.TestCase):
|
|||
|
||||
def test_magic_methods_and_spec_set(self):
|
||||
class Iterable(object):
|
||||
def __iter__(self):
|
||||
pass
|
||||
def __iter__(self): pass
|
||||
|
||||
mock = Mock(spec_set=Iterable)
|
||||
self.assertRaises(AttributeError, lambda: mock.__iter__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue