cubicweb/pyramid/test/__init__.py
author Denis Laxalde <denis.laxalde@logilab.fr>
Thu, 16 May 2019 09:40:28 +0200
changeset 12613 703a263dd618
parent 12593 c30f8dc81f22
permissions -rw-r--r--
Fix flake8 errors/warnings about import in cubicweb/_exceptions.py We either ignore errors in case of name re-exports and drop re-exports from old backwards compatibility. We fix the only occurrence of NoSelectableObject being imported from cubicweb in tests and update the import to use lgc instead.

import webtest

from pyramid.config import Configurator
from cubicweb.devtools.webtest import CubicWebTestTC


class PyramidCWTest(CubicWebTestTC):
    settings = {}

    @classmethod
    def init_config(cls, config):
        super(PyramidCWTest, cls).init_config(config)
        config.global_set_option('anonymous-user', 'anon')

    def setUp(self):
        # Skip CubicWebTestTC setUp
        super(CubicWebTestTC, self).setUp()
        settings = {
            'cubicweb.bwcompat': False,
            'cubicweb.session.secret': 'test',
        }
        settings.update(self.settings)
        config = Configurator(settings=settings)
        config.registry['cubicweb.repository'] = self.repo
        config.include('cubicweb.pyramid')
        self.includeme(config)
        self.pyr_registry = config.registry
        self.webapp = webtest.TestApp(
            config.make_wsgi_app(),
            extra_environ={'wsgi.url_scheme': 'https'})

    def includeme(self, config):
        pass