예제 #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'))
예제 #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'))
예제 #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'))
예제 #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'))
예제 #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)
예제 #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)
예제 #7
0
파일: tests.py 프로젝트: beanbaginc/kgb
    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)
예제 #8
0
파일: tests.py 프로젝트: beanbaginc/kgb
    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)