How to use the pytest.yield_fixture function in pytest

To help you get started, we’ve selected a few pytest examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pytest-dev / pytest / testing / example_scripts / issue_519.py View on Github external
@pytest.yield_fixture(scope="function")
def fix2(request, fix1, arg2, checked_order):
    checked_order.append((request.node.name, "fix2", arg2))
    yield "fix2-" + arg2 + fix1
github dbrattli / aioreactive / test / test_chain.py View on Github external
@pytest.yield_fixture()
def event_loop():
    loop = VirtualTimeEventLoop()
    yield loop
    loop.close()
github CenterForOpenScience / waterbutler / tests / utils.py View on Github external
@pytest.yield_fixture
def temp_files():
    context = TempFilesContext()
    yield context
    context.tear_down()
github aws / aws-encryption-sdk-cli / test / unit / internal / test_logging_utils.py View on Github external
@pytest.yield_fixture
def patch_logging_levels(mocker):
    mocker.patch.object(logging_utils, "_logging_levels")
    yield logging_utils._logging_levels
github d-chambers / Detex / tests / test_cases / template.py View on Github external
@pytest.yield_fixture(scope="session")
def make_data_dirs(load_keys):
    temkey, stakey, phases = load_keys
    detex.getdata.makeDataDirectories(templateKey=temkey, stationKey=stakey)
    # dont delete when finished gitignore will keep it from being pushed  
github nameko / nameko / test / standalone / test_rpc_proxy.py View on Github external
    @pytest.yield_fixture(autouse=True)
    def retry(self, request):
        retry = False
        if "publish_retry" in request.keywords:
            retry = True

        with patch.object(MethodProxy.publisher_cls, 'retry', new=retry):
            yield
github nameko / nameko / test / test_rpc.py View on Github external
    @pytest.yield_fixture
    def get_producer(self):
        with patch('nameko.amqp.publish.get_producer') as get_producer:
            yield get_producer
github moinwiki / moin / src / moin / apps / frontend / _tests / test_frontend.py View on Github external
    @pytest.yield_fixture(autouse=True)
    def custom_setup(self, app):
        saved_user = flaskg.user
        flaskg.user = user.User()
        yield
        flaskg.user = saved_user
github uber-archive / pyflame / tests / test_end_to_end.py View on Github external
@pytest.yield_fixture
def exit_early():
    with python_proc('exit_early.py') as p:
        yield p
github Mirantis / stepler / stepler / cinder / fixtures / transfers.py View on Github external
@pytest.yield_fixture
def create_volume_transfer(transfer_steps):
    """Callable function fixture to create volume transfer with options.

    Can be called several times during test.

    Args:
        transfer_steps (VolumeTransferSteps): instantiated transfer steps

    Yields:
        function: function to create singe volume transfer with options
    """
    volume_transfers = []

    def _create_volume_transfer(*args, **kwgs):
        volume_transfer = transfer_steps.create_volume_transfer(*args, **kwgs)
        volume_transfers.append(volume_transfer)