Example #1
0
def app(request):
    """Fixture for use Webtest (django-webtest)"""
    from django_webtest import WebTestMixin
    wt = WebTestMixin()
    wt._patch_settings()
    request.addfinalizer(wt._unpatch_settings)
    wt.renew_app()
    return wt.app
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()
Example #3
0
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()
Example #4
0
def webtest(request, transactional_db):
    """
    Provide the "app" object from WebTest as a fixture
    Taken and adapted from https://gist.github.com/magopian/6673250
    """
    # Patch settings on startup
    wtm = WebTestMixin()
    wtm._patch_settings()

    # Unpatch settings on teardown
    request.addfinalizer(wtm._unpatch_settings)

    return DjangoTestApp()
Example #5
0
def django_app_factory():
    app_mixin = WebTestMixin()

    def factory(csrf_checks=True, extra_environ=None):
        app_mixin.csrf_checks = csrf_checks
        if extra_environ:
            app_mixin.extra_environ = extra_environ
        app_mixin._patch_settings()
        app_mixin.renew_app()
        return app_mixin.app

    yield factory
    app_mixin._unpatch_settings()
Example #6
0
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.

    source: https://gist.github.com/magopian/6673250
    """
    wtm = WebTestMixin()
    wtm._patch_settings()
    request.addfinalizer(wtm._unpatch_settings)
    return DjangoTestApp()
Example #7
0
def app(request, admin_user):
    """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.

    source: https://gist.github.com/magopian/6673250
    """
    wtm = WebTestMixin()
    wtm._patch_settings()
    request.addfinalizer(wtm._unpatch_settings)
    return SigiTestApp(default_user=admin_user.username)
Example #8
0
def app(request, admin_user):
    """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.

    source: https://gist.github.com/magopian/6673250
    """
    wtm = WebTestMixin()
    wtm._patch_settings()
    request.addfinalizer(wtm._unpatch_settings)
    # XXX change this admin user to "saploper"
    return OurTestApp(default_user=admin_user.username)
Example #9
0
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.

    from: https://gist.github.com/magopian/6673250

    """
    wtm = WebTestMixin()
    wtm._patch_settings()
    request.addfinalizer(wtm._unpatch_settings)
    return DjangoTestApp()
Example #10
0
def webtest(request, webtest_csrf_checks, transactional_db):
    """
    Provide the "app" object from WebTest as a fixture

    Taken and adapted from https://gist.github.com/magopian/6673250
    """
    from django_webtest import DjangoTestApp, WebTestMixin

    # Patch settings on startup
    wtm = WebTestMixin()
    wtm.csrf_checks = webtest_csrf_checks
    wtm._patch_settings()

    # Unpatch settings on teardown
    request.addfinalizer(wtm._unpatch_settings)

    return DjangoTestApp()
Example #11
0
def webtest(request, webtest_csrf_checks):
    """
    Provide the "app" object from WebTest as a fixture

    Taken and adapted from https://gist.github.com/magopian/6673250
    """
    from django_webtest import DjangoTestApp, WebTestMixin

    # Patch settings on startup
    wtm = WebTestMixin()
    wtm.csrf_checks = webtest_csrf_checks
    wtm._patch_settings()

    # Unpatch settings on teardown
    request.addfinalizer(wtm._unpatch_settings)

    return DjangoTestApp()
Example #12
0
def app(request):
    """Fixture for use Webtest (django-webtest)"""
    from django_webtest import WebTestMixin
    wt = WebTestMixin()
    wt._patch_settings()
    request.addfinalizer(wt._unpatch_settings)
    wt.renew_app()
    return wt.app
Example #13
0
def App(request, db):
    mixin = WebTestMixin()
    mixin._patch_settings()
    mixin._disable_csrf_checks()
    request.addfinalizer(mixin._unpatch_settings)

    def factory():
        return DjangoTestApp(extra_environ=mixin.extra_environ)

    return factory
Example #14
0
def django_app_mixin():
    app_mixin = WebTestMixin()
    return app_mixin
Example #15
0
 def app(self):
     wt = WebTestMixin()
     wt._patch_settings()
     wt.renew_app()
     return wt.app
Example #16
0
def app(request):
    wtm = WebTestMixin()
    wtm._patch_settings()
    wtm._disable_csrf_checks()
    request.addfinalizer(wtm._unpatch_settings)
    return DjangoTestApp()
Example #17
0
def app(request):
    wtm = WebTestMixin()
    wtm._patch_settings()
    wtm._disable_csrf_checks()
    request.addfinalizer(wtm._unpatch_settings)
    return DjangoTestApp()