コード例 #1
0
 def test_problematic_add_using_patch(self, mocker):
     """This test patches, i.e. replaces, the problematic code so
        the tests can be carried out.
     """
     # 'mocker' fixture can be used by taking it as an argument, see
     # https://github.com/pytest-dev/pytest-mock/
     mocker.patch("problematic.InfiniteLoopLibrary")
     # problematic.InfiniteLoopLibrary class is now replaced
     # with a mock.MagicMock object when it is instantiated by
     # problematic.Problematic, see
     # http://www.voidspace.org.uk/python/mock/patch.html#patch
     p = Problematic()
     assert p.add_using_external_dependency(1, 1) == 2
コード例 #2
0
 def test_problematic_add(self):
     """"This test would block the test suite and serves as an
         example of the problem. The test is skipped.
     """
     p = Problematic()
     assert p.add_using_external_dependency(1, 1) == 2