Python源码示例:django.WebTestMixin()

示例1
def app(request):
    wtm = django_webtest.WebTestMixin()
    wtm._patch_settings()
    yield django_webtest.DjangoTestApp()
    wtm._unpatch_settings() 
示例2
def new_browser_session(self):
        """
        Creates (and switches to) a new session that is separate from previous
        sessions. Returns a tuple (old_session_token, new_session_token). These
        values should be treated as opaque tokens that can be used with
        switch_browser_session.
        """
        # WebTestMixin creates the instance as 'self.app', so we just just move
        # that value around.
        last_app = self.app
        self.renew_app()
        return (BrowserSessionToken(last_app),
                BrowserSessionToken(self.app)) 
示例3
def app(request):
    """WebTest's TestApp.
    Patch and unpatch settings before and after each test.
    WebTestMixin, when used in a unittest.TestCase, automatically calls
    _patch_settings() and _unpatchsettings.
    """
    wtm = WebTestMixin()
    wtm._patch_settings()
    request.addfinalizer(wtm._unpatch_settings)
    return DjangoTestApp() 
示例4
def app(request):
    """WebTest's TestApp.
    Patch and unpatch settings before and after each test.
    WebTestMixin, when used in a unittest.TestCase, automatically calls
    _patch_settings() and _unpatchsettings.
    """
    wtm = WebTestMixin()
    wtm._patch_settings()
    request.addfinalizer(wtm._unpatch_settings)
    return DjangoTestApp()