Skip to content

Commit 9dd76a8

Browse files
authored
Merge pull request #1285 from newrelic/develop-tests
Merge develop-tests into main
2 parents e4ff798 + 415dc73 commit 9dd76a8

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

newrelic/hooks/framework_starlette.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ def instrument_starlette_middleware_exceptions(module):
252252
def instrument_starlette_exceptions(module):
253253
# ExceptionMiddleware was moved to starlette.middleware.exceptions, need to check
254254
# that it isn't being imported through a deprecation and double wrapped.
255-
if not hasattr(module, "__deprecated__"):
255+
256+
# After v0.45.0, the import proxy for ExceptionMiddleware was removed from starlette.exceptions
257+
if not hasattr(module, "__deprecated__") and hasattr(module, "ExceptionMiddleware"):
256258

257259
wrap_function_wrapper(module, "ExceptionMiddleware.__call__", error_middleware_wrapper)
258260

tests/mlmodel_langchain/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ def openai_clients(openai_version, MockExternalOpenAIServer): # noqa: F811
7373
chat = ChatOpenAI(
7474
base_url=f"http://localhost:{server.port}",
7575
api_key="NOT-A-REAL-SECRET",
76+
temperature=0.7,
7677
)
7778
embeddings = OpenAIEmbeddings(
7879
openai_api_key="NOT-A-REAL-SECRET", openai_api_base=f"http://localhost:{server.port}"

tests/mlmodel_langchain/test_chain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@
525525
"vendor": "langchain",
526526
"ingest_source": "Python",
527527
"virtual_llm": True,
528-
"content": "{'input': 'math', 'context': [Document(metadata={}, page_content='What is 2 + 4?')]}",
528+
"content": "{'input': 'math', 'context': [Document(id='1234', metadata={}, page_content='What is 2 + 4?')]}",
529529
},
530530
],
531531
[
@@ -557,7 +557,7 @@
557557
"ingest_source": "Python",
558558
"is_response": True,
559559
"virtual_llm": True,
560-
"content": "{'input': 'math', 'context': [Document(metadata={}, page_content='What is 2 + 4?')], 'answer': '```html\\n<!DOCTYPE html>\\n<html>\\n<head>\\n <title>Math Quiz</title>\\n</head>\\n<body>\\n <h2>Math Quiz Questions</h2>\\n <ol>\\n <li>What is the result of 5 + 3?</li>\\n <ul>\\n <li>A) 7</li>\\n <li>B) 8</li>\\n <li>C) 9</li>\\n <li>D) 10</li>\\n </ul>\\n <li>What is the product of 6 x 7?</li>\\n <ul>\\n <li>A) 36</li>\\n <li>B) 42</li>\\n <li>C) 48</li>\\n <li>D) 56</li>\\n </ul>\\n <li>What is the square root of 64?</li>\\n <ul>\\n <li>A) 6</li>\\n <li>B) 7</li>\\n <li>C) 8</li>\\n <li>D) 9</li>\\n </ul>\\n <li>What is the result of 12 / 4?</li>\\n <ul>\\n <li>A) 2</li>\\n <li>B) 3</li>\\n <li>C) 4</li>\\n <li>D) 5</li>\\n </ul>\\n <li>What is the sum of 15 + 9?</li>\\n <ul>\\n <li>A) 22</li>\\n <li>B) 23</li>\\n <li>C) 24</li>\\n <li>D) 25</li>\\n </ul>\\n </ol>\\n</body>\\n</html>\\n```'}",
560+
"content": "{'input': 'math', 'context': [Document(id='1234', metadata={}, page_content='What is 2 + 4?')], 'answer': '```html\\n<!DOCTYPE html>\\n<html>\\n<head>\\n <title>Math Quiz</title>\\n</head>\\n<body>\\n <h2>Math Quiz Questions</h2>\\n <ol>\\n <li>What is the result of 5 + 3?</li>\\n <ul>\\n <li>A) 7</li>\\n <li>B) 8</li>\\n <li>C) 9</li>\\n <li>D) 10</li>\\n </ul>\\n <li>What is the product of 6 x 7?</li>\\n <ul>\\n <li>A) 36</li>\\n <li>B) 42</li>\\n <li>C) 48</li>\\n <li>D) 56</li>\\n </ul>\\n <li>What is the square root of 64?</li>\\n <ul>\\n <li>A) 6</li>\\n <li>B) 7</li>\\n <li>C) 8</li>\\n <li>D) 9</li>\\n </ul>\\n <li>What is the result of 12 / 4?</li>\\n <ul>\\n <li>A) 2</li>\\n <li>B) 3</li>\\n <li>C) 4</li>\\n <li>D) 5</li>\\n </ul>\\n <li>What is the sum of 15 + 9?</li>\\n <ul>\\n <li>A) 22</li>\\n <li>B) 23</li>\\n <li>C) 24</li>\\n <li>D) 25</li>\\n </ul>\\n </ol>\\n</body>\\n</html>\\n```'}",
561561
},
562562
],
563563
]
@@ -1814,7 +1814,7 @@ def _test():
18141814
@background_task()
18151815
def test_retrieval_chains(set_trace_info, retrieval_chain_prompt, embedding_openai_client, chat_openai_client):
18161816
set_trace_info()
1817-
documents = [langchain_core.documents.Document(page_content="What is 2 + 4?")]
1817+
documents = [langchain_core.documents.Document(id="1234", page_content="What is 2 + 4?")]
18181818
vectordb = FAISS.from_documents(documents=documents, embedding=embedding_openai_client)
18191819
retriever = vectordb.as_retriever()
18201820
question_answer_chain = create_stuff_documents_chain(

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ envlist =
138138
python-framework_graphql-py37-graphql{0301,0302},
139139
python-framework_pyramid-{py37,py38,py39,py310,py311,py312,py313,pypy310}-Pyramidlatest,
140140
python-framework_pyramid-{py37,py38,py39,py310,py311,py312,py313,pypy310}-Pyramid0110-cornice,
141-
python-framework_sanic-{py37,py38,py39,py310,py311,py312,py313,pypy310}-saniclatest,
141+
python-framework_sanic-{py37,py38}-sanic2406,
142+
python-framework_sanic-{py39,py310,py311,py312,py313,pypy310}-saniclatest,
142143
python-framework_sanic-{py38,pypy310}-sanic{200904,210300,2109,2112,2203,2290},
143144
python-framework_starlette-{py310,pypy310}-starlette{0014,0015,0019,0028},
144145
python-framework_starlette-{py37,py38,py39,py310,py311,py312,py313,pypy310}-starlettelatest,
@@ -359,6 +360,7 @@ deps =
359360
framework_sanic-sanic2112: sanic<21.13
360361
framework_sanic-sanic2203: sanic<22.4
361362
framework_sanic-sanic2290: sanic<22.9.1
363+
framework_sanic-sanic2406: sanic<24.07
362364
framework_sanic-saniclatest: sanic
363365
framework_sanic-sanic{200904,210300,2109,2112,2203,2290}: websockets<11
364366
; For test_exception_in_middleware test, anyio is used:

0 commit comments

Comments
 (0)