How to use the pytest.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 CenterForOpenScience / osf.io / api_tests / providers / preprints / views / test_preprint_provider_list.py View on Github external
@pytest.fixture(params=['/{}preprint_providers/?version=2.2&', '/{}providers/preprints/?version=2.2&'])
def url(request):
    url = (request.param)
    return url.format(API_BASE)
github brabiega / quakestats / tests / unit / test_analyzer_badges.py View on Github external
    @pytest.fixture
    def badger(self):
        scores = mock.Mock()
        scores.name = 'scores'
        special_scores = mock.Mock()
        special_scores.name = 'special_scores'

        return Badger(scores, special_scores)
github Ulauncher / Ulauncher / tests / search / apps / test_app_watcher.py View on Github external
    @pytest.fixture
    def event_handler(self, db):
        AppNotifyEventHandler.RETRY_INTERVAL = 0.05
        AppNotifyEventHandler.RETRY_TIME_SPAN = (0, 30)
        return AppNotifyEventHandler(db)
github OpenGeoscience / geonotebook / tests / test_geonotebook.py View on Github external
@pytest.fixture
def kw_only(nbprotocoldict):
    return nbprotocoldict['kw_only']
github joerick / cibuildwheel / unit_test / main_util_fixtures.py View on Github external
@pytest.fixture(autouse=True)
def fake_project_dir(monkeypatch):
    '''
    Monkey-patch enough for the main() function to run
    '''

    real_os_path_exists = os.path.exists
    def mock_os_path_exists(path):
        if path == os.path.join(MOCK_PROJECT_DIR, 'setup.py'):
            return True
        else:
            return real_os_path_exists(path)

    monkeypatch.setattr(os.path, 'exists', mock_os_path_exists)
    monkeypatch.setattr(sys, 'argv', ['cibuildwheel', MOCK_PROJECT_DIR])
github bbengfort / confire / tests / test_paths.py View on Github external
@pytest.fixture(scope='function', autouse=True)
def destroy_paths():
    yield
    if os.path.exists(MDROOT):
        shutil.rmtree(MDROOT)

    # Delete contents of the test file
    with open(TESTFILE, 'w') as f:
        f.write("")
github OmegaK2 / PyPoE / tests / PyPoE / poe / test_patchserver.py View on Github external
@pytest.fixture(scope='module')
def patch():
    return patchserver.Patch()
github pytest-dev / pytest-mimesis / pytest_mimesis / fixtures.py View on Github external
@pytest.fixture()
def business(locale):
    """

    :param locale:
    :return:
    """
    return Business(locale)
github OSGeo / gdal / autotest / ogr / ogr_geojson.py View on Github external
@pytest.fixture(scope="module")
def startup_and_cleanup():

    gdaltest.geojson_drv = ogr.GetDriverByName('GeoJSON')

    yield
github bradleyhurley / PyBall / test / test_error_parser.py View on Github external
@pytest.fixture()
def error_message(request):
    return {
        'messageNumber': request.param,
        'message': 'test message',
    }