trac.plugins.ticketref / tests / conftest.py

# -*- coding: utf-8 -*-

from trac.test import EnvironmentStub

from ticketref.api import TicketRefsPlugin
from ticketref.web_ui import TicketRefsTemplate

def pytest_addoption(parser):
    group = parser.getgroup("general")
    group.addoption('--envscope',
        action="store", dest="envscope", default="module",
        type="choice", choices=["module", "function"],
        help=("set environment scope, default: module."))

def make_trac_environment_with_plugin():
    env = EnvironmentStub(
        enable=["ticketref.*", TicketRefsPlugin, TicketRefsTemplate])
    TicketRefsPlugin(env).upgrade_environment(env.get_db_cnx())
    tref = TicketRefsPlugin(env)
    tmpl = TicketRefsTemplate(env)
    return env, tref, tmpl

def pytest_funcarg__env(request):
    setup = make_trac_environment_with_plugin
    scope = request.config.option.envscope
    env, tref, tmpl = request.cached_setup(setup=setup, scope=scope)
    return env

def pytest_funcarg__tref(request):
    setup = make_trac_environment_with_plugin
    scope = request.config.option.envscope
    env, tref, tmpl = request.cached_setup(setup=setup, scope=scope)
    return tref

def pytest_funcarg__tmpl(request):
    setup = make_trac_environment_with_plugin
    scope = request.config.option.envscope
    env, tref, tmpl = request.cached_setup(setup=setup, scope=scope)
    return tmpl
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.