-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properly pickle of Timeout objects + test cases (#203)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bernát Gábor <bgabor8@bloomberg.net>
- Loading branch information
1 parent
66b2d49
commit 0b10287
Showing
4 changed files
with
54 additions
and
6 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
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,30 @@ | ||
from __future__ import annotations | ||
|
||
import pickle | ||
|
||
from filelock import Timeout | ||
|
||
|
||
def test_timeout_str() -> None: | ||
timeout = Timeout("/path/to/lock") | ||
assert str(timeout) == "The file lock '/path/to/lock' could not be acquired." | ||
|
||
|
||
def test_timeout_repr() -> None: | ||
timeout = Timeout("/path/to/lock") | ||
assert repr(timeout) == "Timeout('/path/to/lock')" | ||
|
||
|
||
def test_timeout_lock_file() -> None: | ||
timeout = Timeout("/path/to/lock") | ||
assert timeout.lock_file == "/path/to/lock" | ||
|
||
|
||
def test_timeout_pickle() -> None: | ||
timeout = Timeout("/path/to/lock") | ||
timeout_loaded = pickle.loads(pickle.dumps(timeout)) | ||
|
||
assert timeout.__class__ == timeout_loaded.__class__ | ||
assert str(timeout) == str(timeout_loaded) | ||
assert repr(timeout) == repr(timeout_loaded) | ||
assert timeout.lock_file == timeout_loaded.lock_file |