1

Let's consider this example:

class First:
    def register(self, handler):
        pass

class Second:
    def __init__(self, first):
        assert first
        self.__first = first

And test injecting mock:

class TestSecond(PyMockTestCase):
    def test_construction(self):
        first = self.mock()
        sut = Second(first)

This test fails because first does not pass the assertion. If I modify my Second class to test for None, the test will pass:

class Second:
    def __init__(self, first):
        assert first is not None
        self.__first = first

What causes mock to be recognized as False?

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670

0 Answers0