Created
December 5, 2013 19:38
-
-
Save theY4Kman/7812426 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
| from .fixtures import * |
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
| def _keyword_fixture(fn): | |
| fixture_name = fn.__name__ | |
| fixture_module = sys.modules[fn.__module__] | |
| @pytest.fixture(autouse=True) | |
| def _autouse_fixture(request): | |
| if fixture_name in request.keywords: | |
| request.getfuncargvalue(fixture_name) | |
| _autouse_fixture.__name__ = '_{}_autouse'.format(fixture_name) | |
| setattr(fixture_module, _autouse_fixture.__name__, _autouse_fixture) | |
| return fn | |
| def keyword_fixture(scope='function', params=None, autouse=False): | |
| if callable(scope) and params is None and autouse is False: | |
| fn = pytest.fixture(scope) | |
| return _keyword_fixture(fn) | |
| else: | |
| def _inner_keyword_fixture(fn): | |
| fn = pytest.fixture(scope, params, autouse)(fn) | |
| return _keyword_fixture(fn) | |
| return _inner_keyword_fixture | |
| @keyword_fixture | |
| def test(request): | |
| pass |
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 conftest | |
| print dir(conftest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment