From 9a9928ab4f70fbc83e9a2107d0d620b297571252 Mon Sep 17 00:00:00 2001 From: Sebastian Niehus Date: Mon, 12 Aug 2024 11:01:25 +0200 Subject: [PATCH] fix: Overload __exit__ method for NoOpTracer --- src/intelligence_layer/core/tracer/tracer.py | 8 ++++++++ tests/connectors/document_index/test_document_index.py | 2 +- tests/core/tracer/test_in_memory_tracer.py | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/intelligence_layer/core/tracer/tracer.py b/src/intelligence_layer/core/tracer/tracer.py index 91647a536..0beb67c19 100644 --- a/src/intelligence_layer/core/tracer/tracer.py +++ b/src/intelligence_layer/core/tracer/tracer.py @@ -376,6 +376,14 @@ def end(self, timestamp: Optional[datetime] = None) -> None: def export_for_viewing(self) -> Sequence[ExportedSpan]: return [] + def __exit__( + self, + exc_type: Optional[type[BaseException]], + exc_value: Optional[BaseException], + _traceback: Optional[TracebackType], + ) -> None: + pass + class JsonSerializer(RootModel[PydanticSerializable]): root: SerializeAsAny[PydanticSerializable] diff --git a/tests/connectors/document_index/test_document_index.py b/tests/connectors/document_index/test_document_index.py index 6cc69a555..0cbd24311 100644 --- a/tests/connectors/document_index/test_document_index.py +++ b/tests/connectors/document_index/test_document_index.py @@ -198,7 +198,7 @@ def test_document_list_all_documents( ) -> None: filter_result = document_index.documents(collection_path) - assert len(filter_result) == 3 + assert len(filter_result) == 6 def test_document_list_max_n_documents( diff --git a/tests/core/tracer/test_in_memory_tracer.py b/tests/core/tracer/test_in_memory_tracer.py index 530faf0f7..fa41c1487 100644 --- a/tests/core/tracer/test_in_memory_tracer.py +++ b/tests/core/tracer/test_in_memory_tracer.py @@ -99,7 +99,10 @@ def test_task_span_records_error_value() -> None: raise ValueError("my bad, sorry") assert isinstance(tracer.entries[0], InMemoryTaskSpan) - error = tracer.entries[0].output + error_log = tracer.entries[0].entries[0] + assert isinstance(error_log, LogEntry) + + error = error_log.value assert isinstance(error, ErrorValue) assert error.message == "my bad, sorry" assert error.error_type == "ValueError"