Esempio n. 1
0
    def test_spy_on(self):
        """Testing spy_on context manager"""
        obj = MathClass()

        with spy_on(obj.do_math):
            self.assertTrue(hasattr(obj.do_math, 'spy'))

            result = obj.do_math()
            self.assertEqual(result, 3)

        self.assertFalse(hasattr(obj.do_math, 'spy'))
Esempio n. 2
0
    def test_spy_on(self):
        """Testing spy_on context manager"""
        obj = MathClass()

        with spy_on(obj.do_math):
            self.assertTrue(hasattr(obj.do_math, 'spy'))

            result = obj.do_math()
            self.assertEqual(result, 3)

        self.assertFalse(hasattr(obj.do_math, 'spy'))
Esempio n. 3
0
    def test_expose_spy(self):
        """Testing spy_on exposes `spy` via context manager"""
        obj = MathClass()

        with spy_on(obj.do_math) as spy:
            self.assertTrue(hasattr(obj.do_math, 'spy'))
            self.assertIs(obj.do_math.spy, spy)

            result = obj.do_math()
            self.assertEqual(result, 3)

        self.assertFalse(hasattr(obj.do_math, 'spy'))
Esempio n. 4
0
    def test_expose_spy(self):
        """Testing spy_on exposes `spy` via context manager"""
        obj = MathClass()

        with spy_on(obj.do_math) as spy:
            self.assertTrue(hasattr(obj.do_math, 'spy'))
            self.assertIs(obj.do_math.spy, spy)

            result = obj.do_math()
            self.assertEqual(result, 3)

        self.assertFalse(hasattr(obj.do_math, 'spy'))
Esempio n. 5
0
    def test_expose_spy(self):
        """Testing spy_on exposes `spy` via context manager"""
        obj = MathClass()
        orig_do_math = obj.do_math

        with spy_on(obj.do_math) as spy:
            self.assertTrue(isinstance(spy, FunctionSpy))

            result = obj.do_math()
            self.assertEqual(result, 3)

        self.assertEqual(obj.do_math, orig_do_math)
Esempio n. 6
0
    def test_spy_on(self):
        """Testing spy_on context manager"""
        obj = MathClass()
        orig_do_math = obj.do_math

        with spy_on(obj.do_math):
            self.assertTrue(isinstance(obj.do_math, FunctionSpy))

            result = obj.do_math()
            self.assertEqual(result, 3)

        self.assertEqual(obj.do_math, orig_do_math)
Esempio n. 7
0
    def test_expose_spy(self):
        """Testing spy_on exposes `spy` via context manager"""
        obj = MathClass()
        orig_do_math = obj.do_math

        with spy_on(obj.do_math) as spy:
            self.assertTrue(isinstance(spy, FunctionSpy))

            result = obj.do_math()
            self.assertEqual(result, 3)

        self.assertEqual(obj.do_math, orig_do_math)
Esempio n. 8
0
    def test_spy_on(self):
        """Testing spy_on context manager"""
        obj = MathClass()
        orig_do_math = obj.do_math

        with spy_on(obj.do_math):
            self.assertTrue(isinstance(obj.do_math, FunctionSpy))

            result = obj.do_math()
            self.assertEqual(result, 3)

        self.assertEqual(obj.do_math, orig_do_math)