-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Any | ||
|
||
|
||
class EqMock: | ||
value: Any = None | ||
|
||
def __init__(self, remember: bool = False) -> None: | ||
self.remember: bool = remember | ||
|
||
def __eq__(self, other: Any) -> bool: # noqa: ANN401 | ||
if self.remember and self.value is not None: | ||
return self.value == other | ||
else: | ||
assert other, other | ||
|
||
if self.remember: | ||
self.value = other | ||
|
||
return True | ||
|
||
def __repr__(self) -> str: | ||
return repr(self.value) if self.remember else super().__repr__() | ||
|
||
def __str__(self) -> str: | ||
return str(self.value) if self.remember else super().__str__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Any | ||
|
||
|
||
class EqMock: | ||
value: Any = None | ||
|
||
def __init__(self, remember: bool = False) -> None: | ||
self.remember: bool = remember | ||
|
||
def __eq__(self, other: Any) -> bool: # noqa: ANN401 | ||
if self.remember and self.value is not None: | ||
return self.value == other | ||
else: | ||
assert other, other | ||
|
||
if self.remember: | ||
self.value = other | ||
|
||
return True | ||
|
||
def __repr__(self) -> str: | ||
return repr(self.value) if self.remember else super().__repr__() | ||
|
||
def __str__(self) -> str: | ||
return str(self.value) if self.remember else super().__str__() |