def test_no_nested_internal_instance_method_tracing_log_records_when_trace_disabled(
            self):
        named_tracer.setLevel(logging.DEBUG)
        value = TracedClass._TracedClass__InternalNestedClass().method(None)

        self.assertEqual("TC.__INC.m None and None", value)
        self.assertEqual(0, len(list_handler.records))
    def test_init_method_tracing_log_records(self):
        obj = TracedClass()

        self.assertEqual("TC.%s %s and %s", obj.format_string)
        self.assertEqual(2, len(list_handler.records))

        traced_function = TracedClass.__dict__["__init__"].__wrapped__
        self._assert_call_record(list_handler.records[0], traced_function,
                                 "test.dummy.TracedClass", (tuple(), dict()),
                                 "TC.__i__")
        self._assert_return_record(list_handler.records[1], traced_function,
                                   "test.dummy.TracedClass", (None, ),
                                   "TC.__i__")
    def test_staticmethod_tracing_log_records(self):
        value = TracedClass.static_method(None)

        self.assertEqual("TC.s_m None and None", value)
        self.assertEqual(2, len(list_handler.records))

        traced_function = \
            TracedClass.__dict__["static_method"].__func__.__wrapped__
        self._assert_call_record(list_handler.records[0], traced_function,
                                 "test.dummy.TracedClass", ((None, ), dict()),
                                 "TC.s_m")
        self._assert_return_record(list_handler.records[1], traced_function,
                                   "test.dummy.TracedClass",
                                   ("TC.s_m None and None", ), "TC.s_m")
Beispiel #4
0
    def test_staticmethod_tracing_log_records(self):
        value = TracedClass.static_method(None)

        self.assertEqual("TC.s_m None and None", value)
        self.assertEqual(2, len(list_handler.records))

        traced_function = \
            TracedClass.__dict__["static_method"].__func__.__wrapped__
        self._assert_call_record(
            list_handler.records[0], traced_function, "test.dummy.TracedClass",
            ((None,), dict()), "TC.s_m")
        self._assert_return_record(
            list_handler.records[1], traced_function, "test.dummy.TracedClass",
            ("TC.s_m None and None",), "TC.s_m")
    def test_nested_class_instance_method_tracing_log_records(self):
        obj = TracedClass.NestedClass()

        self.assertEqual("TC.NC.%s %s and %s", obj.format_string)
        self.assertEqual(2, len(list_handler.records))

        traced_function = \
            TracedClass.NestedClass.__dict__["__init__"].__wrapped__
        expected_logger_name = "test.dummy.%s" % getattr(
            TracedClass.NestedClass, "__qualname__", "NestedClass")
        self._assert_call_record(list_handler.records[0], traced_function,
                                 expected_logger_name, (tuple(), dict()),
                                 "TC.NC.__i__")
        self._assert_return_record(list_handler.records[1], traced_function,
                                   expected_logger_name, (None, ),
                                   "TC.NC.__i__")
    def test_call_method_tracing_log_records(self):
        obj = TracedClass()

        list_handler.reset()
        rv = obj()

        self.assertEqual("TC.__call__", rv)
        self.assertEqual(2, len(list_handler.records))

        traced_function = TracedClass.__dict__["__call__"].__wrapped__
        self._assert_call_record(list_handler.records[0], traced_function,
                                 "test.dummy.TracedClass", (tuple(), dict()),
                                 "TC.__c__")
        self._assert_return_record(list_handler.records[1], traced_function,
                                   "test.dummy.TracedClass", ("TC.__call__", ),
                                   "TC.__c__")
    def test_nested_internal_instance_method_tracing_log_records(self):
        value = TracedClass._TracedClass__InternalNestedClass().method(None)

        self.assertEqual("TC.__INC.m None and None", value)
        self.assertEqual(2, len(list_handler.records))

        traced_function = (TracedClass._TracedClass__InternalNestedClass.
                           __dict__["method"].__wrapped__)
        expected_logger_name = "traced.testing.%s" % getattr(
            TracedClass._TracedClass__InternalNestedClass, "__qualname__",
            TracedClass._TracedClass__InternalNestedClass.__name__)
        self._assert_call_record(list_handler.records[0], traced_function,
                                 expected_logger_name, ((None, ), dict()),
                                 "TC.__INC.m")
        self._assert_return_record(list_handler.records[1], traced_function,
                                   expected_logger_name,
                                   ("TC.__INC.m None and None", ),
                                   "TC.__INC.m")
Beispiel #8
0
    def test_nested_internal_instance_method_tracing_log_records(self):
        value = TracedClass._TracedClass__InternalNestedClass().method(None)

        self.assertEqual("TC.__INC.m None and None", value)
        self.assertEqual(2, len(list_handler.records))

        traced_function = (
            TracedClass._TracedClass__InternalNestedClass.
                __dict__["method"].__wrapped__)
        expected_logger_name = "traced.testing.%s" % getattr(
            TracedClass._TracedClass__InternalNestedClass, "__qualname__",
            TracedClass._TracedClass__InternalNestedClass.__name__)
        self._assert_call_record(
            list_handler.records[0], traced_function, expected_logger_name,
            ((None,), dict()), "TC.__INC.m")
        self._assert_return_record(
            list_handler.records[1], traced_function, expected_logger_name,
            ("TC.__INC.m None and None",), "TC.__INC.m")
    def test_no_tracing_log_records_when_trace_disabled(self):
        dummy_module_logger.setLevel(logging.DEBUG)
        obj = TracedClass()

        self.assertEqual(0, len(list_handler.records))
Beispiel #10
0
    def test_no_nested_internal_instance_method_tracing_log_records_when_trace_disabled(self):
        named_tracer.setLevel(logging.DEBUG)
        value = TracedClass._TracedClass__InternalNestedClass().method(None)

        self.assertEqual("TC.__INC.m None and None", value)
        self.assertEqual(0, len(list_handler.records))