-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a timeout to the os.read function (#205)
- Loading branch information
Showing
2 changed files
with
55 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from time import sleep, time | ||
|
||
import pytest | ||
|
||
from acquire.volatilestream import timeout | ||
|
||
|
||
def test_timeout(): | ||
def snooze(): | ||
sleep(10) | ||
|
||
function = timeout(snooze, timelimit=5) | ||
start = time() | ||
|
||
with pytest.raises(TimeoutError): | ||
function() | ||
|
||
end = time() | ||
|
||
assert end - start < 6 |