Skip to content

Commit 5ba7efc

Browse files
committed
use create_autospec
1 parent de1bca5 commit 5ba7efc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pylabrobot/liquid_handling/liquid_handler.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import json
99
import logging
1010
import threading
11+
import unittest.mock
1112
import warnings
1213
from typing import (
1314
Any,
@@ -290,6 +291,10 @@ def _check_args(
290291
The set of arguments that need to be removed from `backend_kwargs` before passing to `method`.
291292
"""
292293

294+
# if method is an AsyncMock, skip the checks
295+
if isinstance(method, unittest.mock.AsyncMock):
296+
return set()
297+
293298
default_args = default.union({"self"})
294299

295300
sig = inspect.signature(method)

pylabrobot/liquid_handling/liquid_handler_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,9 +650,9 @@ async def test_return_tips96(self):
650650
async def test_aspirate_dispense96(self):
651651
await self.lh.pick_up_tips96(self.tip_rack)
652652
await self.lh.aspirate96(self.plate, volume=10)
653-
self.lh.backend.dispense96 = unittest.mock.AsyncMock() # type: ignore
654-
await self.lh.dispense96(self.plate, volume=10)
655-
self.lh.backend.dispense96.assert_called_with(
653+
self.lh.backend.dispense96 = unittest.mock.create_autospec(self.lh.backend.dispense96) # type: ignore
654+
await self.lh.dispense96(self.plate, 10)
655+
self.lh.backend.dispense96.assert_called_with( # type: ignore
656656
dispense=MultiHeadDispensePlate(
657657
wells=self.plate.get_all_items(),
658658
offset=Coordinate.zero(),

0 commit comments

Comments
 (0)