def METHOD_NAME(engine_name, pytest_options):
    # Get test file paths.
    paths = []
    for name in engine_tests_dict[engine_name]:
        if name.startswith("test_"):
            # Use full module paths so pytest can import the files
            # correctly.
            name = "dragonfly/test/" + name + ".py"
        paths.append(name)
    # Initialize the engine and call connect().
    engine_params = engine_params_dict.get(engine_name, {})
    engine = get_engine(engine_name, **engine_params)
    engine.connect()
    # Prevent the engine from running timers on its own. This lets us
    # avoid race conditions.
    engine._timer_manager.disable()
    try:
        # Run doctests through pytest.main() now that the engine is set up.
        # Pass any specified pytest options, followed by doctest options for
        # compatibility with both Python 2.7 and 3.
        args = pytest_options + [
            '-o',
            'doctest_optionflags=ALLOW_UNICODE IGNORE_EXCEPTION_DETAIL'
        ] + paths
        return pytest.main(args)
    finally:
        # Disconnect after the tests.
        engine.disconnect()
        # Check that the dragonfly engine was not changed during the tests.
        assert engine is get_engine(), \
            "The registered engine changed during the test suite."