Created
September 26, 2013 12:38
-
-
Save hpk42/6713581 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import pytest | |
import contextlib | |
@contextlib.contextmanager | |
def ctx(): | |
print "setup ctx" | |
yield 1 | |
print "teardown ctx" | |
@pytest.fixture | |
def fix(request): | |
with request.wrap_contextmanager(ctx()) as x: | |
return x | |
def test_fix(fix): | |
print "test called" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it prints:
setup ctx
test called
teardown ctx