|
6 | 6 | """
|
7 | 7 |
|
8 | 8 | import os
|
9 |
| -from typing import Sequence |
| 9 | +from typing import Sequence, Union |
10 | 10 |
|
11 | 11 | from .spy_events import SpyEvent, SpyRehearsal, VerifyRehearsal
|
12 | 12 | from .stringify import stringify_call, stringify_error_message, count
|
@@ -74,14 +74,18 @@ class RedundantVerifyWarning(DecoyWarning):
|
74 | 74 | [RedundantVerifyWarning guide]: usage/errors-and-warnings.md#redundantverifywarning
|
75 | 75 | """
|
76 | 76 |
|
77 |
| - def __init__(self, rehearsal: VerifyRehearsal) -> None: |
78 |
| - message = os.linesep.join( |
79 |
| - [ |
80 |
| - "The same rehearsal was used in both a `when` and a `verify`.", |
81 |
| - "This is redundant and probably a misuse of the mock.", |
82 |
| - f"\t{stringify_call(rehearsal)}", |
83 |
| - "See https://michael.cousins.io/decoy/usage/errors-and-warnings/#redundantverifywarning", |
84 |
| - ] |
| 77 | + def __init__(self, rehearsal: Union[VerifyRehearsal, str]) -> None: |
| 78 | + message = ( |
| 79 | + os.linesep.join( |
| 80 | + [ |
| 81 | + "The same rehearsal was used in both a `when` and a `verify`.", |
| 82 | + "This is redundant and probably a misuse of the mock.", |
| 83 | + f"\t{stringify_call(rehearsal)}", |
| 84 | + "See https://michael.cousins.io/decoy/usage/errors-and-warnings/#redundantverifywarning", |
| 85 | + ] |
| 86 | + ) |
| 87 | + if isinstance(rehearsal, VerifyRehearsal) |
| 88 | + else rehearsal |
85 | 89 | )
|
86 | 90 | super().__init__(message)
|
87 | 91 | self.rehearsal = rehearsal
|
|
0 commit comments