-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
9 changed files
with
160 additions
and
12 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
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
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
from typing import Any, Optional | ||
from typing import Any, Optional, Union | ||
|
||
from pykka import Future | ||
|
||
class Envelope: | ||
message: Any | ||
reply_to: Optional[Future] | ||
timestamp: float | ||
def __init__( | ||
self, message: Any, reply_to: Optional[Future] = ... | ||
self, | ||
message: Any, | ||
reply_to: Optional[Future] = ..., | ||
delay: Union[float, int] = ..., | ||
) -> None: ... | ||
def __repr__(self) -> 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
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
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
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
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
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 |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import re | ||
import time | ||
|
||
from pykka._envelope import Envelope | ||
|
||
|
||
def test_envelope_repr(): | ||
envelope = Envelope("message", reply_to=123) | ||
current_time = time.time() | ||
delay = 10 | ||
envelope = Envelope("message", reply_to=123, delay=delay) | ||
match = re.match( | ||
r"Envelope\(message='message', reply_to=123, timestamp=([\d\.]+)\)", | ||
repr(envelope), | ||
) | ||
|
||
assert repr(envelope) == "Envelope(message='message', reply_to=123)" | ||
assert match is not None | ||
# there will be some difference, execution takes time | ||
assert abs(float(match.group(1)) - current_time - delay) < 0.1 |