MCPcopy
hub / github.com/jarun/buku / _env_fixture

Function _env_fixture

tests/test_views.py:38–46  ·  view source on GitHub ↗
(dbfile, monkeypatch, request)

Source from the content-addressed store, hash-verified

36def env_fixture(name, **kwargs): # place this fixture BEFORE app or its dependencies
37 """Produces a fixture that mocks a test parameter directly in an env var (before app init)"""
38 def _env_fixture(dbfile, monkeypatch, request):
39 if request.param is not None: # default value placeholder
40 monkeypatch.setenv(name, str(request.param))
41 app = server.create_app(dbfile)
42 app.config.update({'TESTING': True, 'WTF_CSRF_ENABLED': False})
43 yield request.param
44 flask.g.bukudb.close()
45 if os.path.exists(dbfile):
46 os.remove(dbfile)
47 return pytest.fixture(**kwargs)(_env_fixture)
48
49

Callers

nothing calls this directly

Calls 1

closeMethod · 0.80

Tested by

no test coverage detected