Skip to content

Commit cf8b219

Browse files
committed
fix(tests): add sleep in timing tests for Windows timer resolution
Windows time.time() has ~15ms granularity. An instant mock function gets identical start/end timestamps. Add asyncio.sleep(0.02) so duration is always measurable.
1 parent d1b9b57 commit cf8b219

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tests/test_logging.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
import asyncio
17+
1618
import pytest
1719

1820
from nemoguardrails.actions.llm.utils import _log_prompt, _update_token_stats
@@ -125,6 +127,7 @@ async def test_tracks_timing_and_appends_to_processing_log(self):
125127

126128
@track_llm_call
127129
async def mock_llm_call():
130+
await asyncio.sleep(0.02)
128131
return "response"
129132

130133
result = await mock_llm_call()
@@ -168,6 +171,7 @@ async def test_increments_total_time_stat(self):
168171

169172
@track_llm_call
170173
async def mock_llm_call():
174+
await asyncio.sleep(0.02)
171175
return "response"
172176

173177
await mock_llm_call()

0 commit comments

Comments
 (0)