File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
python/selfie-lib/selfie_lib Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
- from typing import Any , TypeVar , overload
1
+ from typing import Any , Callable , TypeVar , overload
2
2
3
3
from .Lens import Camera
4
4
from .SelfieImplementations import BinarySelfie , DiskSelfie , ReprSelfie , StringSelfie
@@ -28,10 +28,18 @@ def expect_selfie(actual: T) -> ReprSelfie[T]: ...
28
28
def expect_selfie (actual : T , camera : Camera [T ]) -> StringSelfie : ...
29
29
30
30
31
+ @overload
32
+ def expect_selfie (actual : T , camera : Callable [[T ], Snapshot ]) -> StringSelfie : ...
33
+
34
+
31
35
def expect_selfie (actual : Any , camera : Any = None ) -> DiskSelfie :
32
36
disk_storage = _selfieSystem ().disk_thread_local ()
33
37
if camera is not None :
34
- return StringSelfie (camera .snapshot (actual ), disk_storage )
38
+ if isinstance (camera , Camera ):
39
+ actual_snapshot = camera .snapshot (actual )
40
+ else :
41
+ actual_snapshot = camera (actual )
42
+ return StringSelfie (actual_snapshot , disk_storage )
35
43
elif isinstance (actual , str ):
36
44
return StringSelfie (Snapshot .of (actual ), disk_storage )
37
45
elif isinstance (actual , Snapshot ):
You can’t perform that action at this time.
0 commit comments