Skip to content

Commit 8fd01cd

Browse files
committed
fix flaky test
1 parent 27694a0 commit 8fd01cd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tests/test_langchain.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,6 +2339,8 @@ def test_cached_token_usage():
23392339
config = {"callbacks": [handler]}
23402340

23412341
chain.invoke({"test_param": "in a funny way"}, config)
2342+
chain.invoke({"test_param": "in a funny way"}, config)
2343+
sleep(1)
23422344

23432345
# invoke again to force cached token usage
23442346
chain.invoke({"test_param": "in a funny way"}, config)
@@ -2359,8 +2361,11 @@ def test_cached_token_usage():
23592361

23602362
assert generation.cost_details["input_cache_read"] > 0
23612363
assert (
2362-
generation.cost_details["input"]
2363-
+ generation.cost_details["input_cache_read"]
2364-
+ generation.cost_details["output"]
2365-
== generation.cost_details["total"]
2364+
abs(
2365+
generation.cost_details["input"]
2366+
+ generation.cost_details["input_cache_read"]
2367+
+ generation.cost_details["output"]
2368+
- generation.cost_details["total"]
2369+
)
2370+
< 0.0001
23662371
)

0 commit comments

Comments
 (0)