def test_function_stop_log_record(self):
        gi = gf(2)
        proxy = _GeneratorIteratorTracingProxy(gf, gi, _module_logger)

        self.assertEqual(1, next(proxy))
        self.assertEqual(2, next(proxy))
        self.assertRaises(StopIteration, next, proxy)
        self.assertEqual(3, len(list_handler.records))

        record = list_handler.records[2]
        self.assertEqual(_module_logger.name, record.name)
        self.assertEqual("STOP %r", record.msg)
        self.assertEqual((gi, ), record.args)
        self.assertEqual("TRACE", record.levelname)
        self.assertEqual(TRACE, record.levelno)
        self.assertEqual(_expected_function_filename, record.pathname)
        self.assertEqual(_expected_function_LS, record.lineno)
        self.assertEqual("gf", record.funcName)
    def test_method_stop_log_record(self):
        obj = Class()
        gi = obj.gm(2)
        proxy = _GeneratorIteratorTracingProxy(obj.gm, gi, _class_logger)

        self.assertEqual(1, next(proxy))
        self.assertEqual(2, next(proxy))
        self.assertRaises(StopIteration, next, proxy)
        self.assertEqual(3, len(list_handler.records))

        record = list_handler.records[2]
        self.assertEqual(_class_logger.name, record.name)
        self.assertEqual("STOP %r", record.msg)
        self.assertEqual((gi, ), record.args)
        self.assertEqual("TRACE", record.levelname)
        self.assertEqual(TRACE, record.levelno)
        self.assertEqual(_expected_method_filename, record.pathname)
        self.assertEqual(_expected_method_LS, record.lineno)
        self.assertEqual("gm", record.funcName)
    def test_function_yield1_log_record(self):
        gi = gf(2)
        proxy = _GeneratorIteratorTracingProxy(gf, gi, _module_logger)

        self.assertEqual(1, next(proxy))
        self.assertEqual(1, len(list_handler.records))

        record = list_handler.records[0]
        self.assertEqual(_module_logger.name, record.name)
        self.assertEqual("YIELD %r %r", record.msg)
        self.assertEqual((
            gi,
            1,
        ), record.args)
        self.assertEqual("TRACE", record.levelname)
        self.assertEqual(TRACE, record.levelno)
        self.assertEqual(_expected_function_filename, record.pathname)
        self.assertEqual(_expected_function_LY, record.lineno)
        self.assertEqual("gf", record.funcName)
    def test_method_yield1_log_record(self):
        obj = Class()
        gi = obj.gm(2)
        proxy = _GeneratorIteratorTracingProxy(obj.gm, gi, _class_logger)

        self.assertEqual(1, next(proxy))
        self.assertEqual(1, len(list_handler.records))

        record = list_handler.records[0]
        self.assertEqual(_class_logger.name, record.name)
        self.assertEqual("YIELD %r %r", record.msg)
        self.assertEqual((
            gi,
            1,
        ), record.args)
        self.assertEqual("TRACE", record.levelname)
        self.assertEqual(TRACE, record.levelno)
        self.assertEqual(_expected_method_filename, record.pathname)
        self.assertEqual(_expected_method_LY, record.lineno)
        self.assertEqual("gm", record.funcName)
    def test_function_close_log_record(self):
        gi = gf(2)
        proxy = _GeneratorIteratorTracingProxy(gf, gi, _module_logger)

        proxy.close()
        self.assertRaises(StopIteration, next, proxy)
        self.assertEqual(2, len(list_handler.records))  # CLOSE, STOP

        record = list_handler.records[0]
        self.assertEqual(_module_logger.name, record.name)
        self.assertEqual("CLOSE %r", record.msg)
        self.assertEqual((gi, ), record.args)
        self.assertEqual("TRACE", record.levelname)
        self.assertEqual(TRACE, record.levelno)
        self.assertEqual(_expected_function_filename, record.pathname)
        # in Jython, the generator iterator doesn't even have a line number
        # at this point (it's 0)
        self.assertEqual(_expected_function_L1 if not _is_jython else 0,
                         record.lineno)
        self.assertEqual("gf", record.funcName)
    def test_function_throw_log_record(self):
        gi = gf(2)
        proxy = _GeneratorIteratorTracingProxy(gf, gi, _module_logger)
        testex = TestException("test")

        self.assertRaises(TestException, proxy.throw, testex)
        self.assertEqual(1, len(list_handler.records))

        record = list_handler.records[0]
        self.assertEqual(_module_logger.name, record.name)
        self.assertEqual("THROW %r %r", record.msg)
        self.assertEqual((
            gi,
            testex,
        ), record.args)
        self.assertEqual("TRACE", record.levelname)
        self.assertEqual(TRACE, record.levelno)
        self.assertEqual(_expected_function_filename, record.pathname)
        # in Jython, the generator iterator doesn't even have a line number
        # at this point (it's 0)
        self.assertEqual(_expected_function_L1 if not _is_jython else 0,
                         record.lineno)
        self.assertEqual("gf", record.funcName)
    def test_function_send_log_record(self):
        gi = gf(2)
        proxy = _GeneratorIteratorTracingProxy(gf, gi, _module_logger)

        # proxy.send(None) should be equivalent to next(proxy)
        self.assertEqual(1, proxy.send(None))
        self.assertEqual(1, len(list_handler.records))

        record = list_handler.records[0]
        self.assertEqual(_module_logger.name, record.name)
        self.assertEqual("SEND %r %r", record.msg)
        self.assertEqual((
            gi,
            None,
        ), record.args)
        self.assertEqual("TRACE", record.levelname)
        self.assertEqual(TRACE, record.levelno)
        self.assertEqual(_expected_function_filename, record.pathname)
        # in Jython, the generator iterator doesn't even have a line number
        # at this point (it's 0)
        self.assertEqual(_expected_function_L1 if not _is_jython else 0,
                         record.lineno)
        self.assertEqual("gf", record.funcName)