forked from ApeWorX/ape
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pytest): fix double yield problem in isolation fixture [APE-1353] (…
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
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,31 @@ | ||
import pytest | ||
|
||
from ape.exceptions import BlockNotFoundError | ||
from ape.pytest.fixtures import PytestApeFixtures | ||
|
||
|
||
@pytest.fixture | ||
def receipt_capture(mocker): | ||
return mocker.MagicMock() | ||
|
||
|
||
@pytest.fixture | ||
def fixtures(mocker, receipt_capture): | ||
return PytestApeFixtures(mocker.MagicMock(), receipt_capture) | ||
|
||
|
||
@pytest.fixture | ||
def isolation(fixtures): | ||
return fixtures._isolation() | ||
|
||
|
||
def test_isolation(isolation, receipt_capture): | ||
# Set up receipt capture to fail on __exit__ | ||
# AFTER the yield statement. There was a bug | ||
# where we got a double-yield in this situation. | ||
|
||
receipt_capture.__exit__.side_effect = BlockNotFoundError(0) | ||
|
||
assert next(isolation) is None | ||
with pytest.raises(StopIteration): | ||
next(isolation) |