[PATCH] INPROGRESS: try (and fail) to enable testsuite under turbogears

Thomas De Schampheleire patrickdepinguin at gmail.com
Wed Mar 9 19:14:14 UTC 2016


# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1457456068 -3600
#      Tue Mar 08 17:54:28 2016 +0100
# Node ID c2d27f1832bb6388826ee93d27d6802369d1e9d6
# Parent  0c3ba1a9ad613c2a410fbe4c98b9acf503493d21
INPROGRESS: try (and fail) to enable testsuite under turbogears

Error:
(the @@@@@@@ lines are some traces I added in turbogears itself)

$ py.test kallithea/tests/other/test_dummy.py
@@@@@@@@@@@@@@@@@ load_environment
@@@@@@@@@@@@@@@@@ load_environment2
@@@@@@@@@@@@@@@@@ load_environment3
@@@@@@@@@@@@@@@@@ load_environment4
@@@@@@@@@@@@@@@@@ load_environment5
@@@@@@@@@@@@@@@@@ load_environment6
@@@@@@@@@@@@@@@@@ setup_persistence
@@@@@@@@@@@@@@@@@ setup persistence 2
{'package_name': 'kallithea', 'errormator.log_namespace_blacklist': '', 'celery.imports': 'kallithea.lib.celerylib.tasks', 'tg.strict_tmpl_context': True, 'use_htsts': 'false', 'tm.enabled': True, 'use_dotted_templatenames': False, 'use_toscawidgets': False, 'issue_prefix': '#', 'errormator.slow_request_time': '1', 'rss_items_per_page': '10', 'beaker.cache.long_term.key_length': '256', 'application_wrappers_dependencies': {False: [], True: [<class 'tg.appwrappers.i18n.I18NApplicationWrapper'>, <class 'tg.appwrappers.identity.IdentityApplicationWrapper'>, <class 'tg.appwrappers.session.SessionApplicationWrapper'>, <class 'tg.appwrappers.caching.CacheApplicationWrapper'>, <class 'tg.appwrappers.mingflush.MingApplicationWrapper'>, <class 'tg.appwrappers.transaction_manager.TransactionApplicationWrapper'>, <class 'tg.appwrappers.errorpage.ErrorPageApplicationWrapper'>], None: []}, 'localedir': '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/i18n', 'app_conf': {'celeryd.max.tasks.per.child': '1', 'broker.host': 'localhost', 'errormator.report_404': 'false', 'errormator.request_keys_blacklist': '', 'beaker.cache.sql_cache_short.type': 'memory', 'default_encoding': 'utf8', 'errormator.log_namespace_blacklist': '', 'celery.imports': 'kallithea.lib.celerylib.tasks', 'beaker.cache.short_term.type': 'memory', 'app_instance_uuid': 'test', 'use_htsts': 'false', 'celery.result.dburi': 'amqp://', 'celeryd.log.level': 'DEBUG', 'issue_prefix': '#', 'errormator.slow_request_time': '1', 'rss_items_per_page': '10', 'beaker.cache.sql_cache_short.key_length': '256', 'errormator.logging_on_error': 'false', 'errormator.server_url': 'https://api.errormator.com', 'errormator.api_key': 'YOUR_API_KEY', 'force_https': 'false', 'celery.always.eager': 'false', 'sqlalchemy.url': 'sqlite:////home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/kallithea_test.sqlite', 'commit_parse_limit': '25', 'beaker.cache.long_term.type': 'memory', 'sqlalchemy.echo': 'false', 'errormator': 'false', 'git_path': 'git', 'cache_dir': '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/data', 'celery.result.backend': 'amqp', 'vcs_full_cache': 'false', 'sentry.site': '', 'sqlalchemy.pool_recycle': '3600', 'auth_ret_code': '', 'archive_cache_dir': '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/tarballcache', 'sentry.project': '', 'show_revision_number': 'true', 'issue_pat': '(?:\\s*#)(\\d+)', 'broker.password': 'qweqwe', 'sentry.exclude_paths': '', 'api_access_controllers_whitelist': '', 'errormator.environ_keys_whitelist': '', 'sentry.servers': '', 'beaker.session.timeout': '2592000', 'beaker.cache.sql_cache_short.expire': '1', 'allow_repo_location_change': 'True', 'celery.result.serialier': 'json', 'show_sha_length': '12', 'errormator.slow_requests': 'true', 'broker.vhost': 'rabbitmqhost', 'beaker.session.httponly': 'true', 'beaker.cache.short_term.expire': '60', 'allow_custom_hooks_settings': 'True', 'beaker.cache.lock_dir': '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/data/cache/lock', 'rss_include_diff': 'false', 'logview.sqlalchemy': '#faa', 'beaker.cache.long_term.expire': '36000', 'rss_cut_off_limit': '256000', 'use_celery': 'false', 'index_dir': '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/data/index', 'logview.pylons.templating': '#bfb', 'broker.port': '5672', 'logview.pylons.util': '#eee', 'static_files': 'true', 'broker.user': 'rabbitmq', 'sentry.secret_key': '', 'lock_ret_code': '423', 'sentry.name': '', 'issue_server_link': 'https://issues.example.com/{repo}/issue/{id}', 'sentry.include_paths': '', 'gist_alias_url': '', 'lang': '', 'sentry.public_key': '', 'beaker.cache.data_dir': '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/data/cache/data', 'cut_off_limit': '256000', 'beaker.cache.short_term.key_length': '256', 'sentry.dsn': 'YOUR_DNS', 'beaker.cache.long_term.key_length': '256', 'beaker.cache.regions': 'short_term,long_term,sql_cache_short', 'sentry.key': '', 'beaker.session.key': 'kallithea', 'celeryd.concurrency': '2', 'beaker.session.secret': '{74e0cd75-b339-478b-b129-07dd221def1f}', 'initial_repo_scan': 'true'}, 'controller_caller': <function call_controller at 0x7f9cea7bea28>, 'disable_request_extensions': False, 'custom_tw2_config': {}, 'sentry.include_paths': '', 'sqlalchemy.url': 'sqlite:////home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/kallithea_test.sqlite', 'global_conf': {'debug': 'false', '__file__': '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/test.ini', 'pdebug': 'false', 'here': '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests'
@@@@@@@@@@@@@@@@@ sqlalchemy
@@@@@@@@@@@@@@@@@ sqlalchemy inside
@@@@@@@@@@@@@@@@@ sqlalchemy inside, not balanced
@@@@@@@@@@@@@@@@@ sqlalchemy inside, engine=Engine(sqlite:////home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/kallithea_test.sqlite)
<module 'kallithea.model' from '/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/model/__init__.pyc'>
@@@@@@@@@@@@@@@@@ after init model
@@@@@@@@@@@@@@@@@ sqlalchemy inside end
@@@@@@@@@@@@@@@@@ sqlalchemy2
@@@@@@@@@@@@@@@@@ load_environment7
@@@@@@@@@@@@@@@@@ load_environment8
No handlers could be found for logger "tg.appwrappers.transaction_manager"
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/venv/kallithea-tg/lib/python2.7/site-packages/pytest-2.8.7-py2.7.egg/_pytest/main.py", line 86, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/venv/kallithea-tg/lib/python2.7/site-packages/pytest-2.8.7-py2.7.egg/_pytest/config.py", line 834, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/venv/kallithea-tg/lib/python2.7/site-packages/pytest-2.8.7-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 729, in call_historic
INTERNALERROR>     self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/venv/kallithea-tg/lib/python2.7/site-packages/pytest-2.8.7-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/venv/kallithea-tg/lib/python2.7/site-packages/pytest-2.8.7-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/venv/kallithea-tg/lib/python2.7/site-packages/pytest-2.8.7-py2.7.egg/_pytest/vendored_packages/pluggy.py", line 596, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/tests/conftest.py", line 20, in pytest_configure
INTERNALERROR>     kallithea.tests.pylonsapp = loadapp('config:kallithea/tests/test.ini', relative_to=path)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/.eggs/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 247, in loadapp
INTERNALERROR>     return loadobj(APP, uri, name=name, **kw)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/.eggs/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 272, in loadobj
INTERNALERROR>     return context.create()
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/.eggs/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 710, in create
INTERNALERROR>     return self.object_type.invoke(self)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/.eggs/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/loadwsgi.py", line 146, in invoke
INTERNALERROR>     return fix_call(context.object, context.global_conf, **context.local_conf)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/.eggs/PasteDeploy-1.5.2-py2.7.egg/paste/deploy/util.py", line 55, in fix_call
INTERNALERROR>     val = callable(*args, **kw)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/config/middleware.py", line 36, in make_app
INTERNALERROR>     app = make_base_app(global_conf, full_stack=True, **app_conf)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/tg2/tg/configuration/app_config.py", line 1322, in make_base_app
INTERNALERROR>     tg.hooks.notify('configure_new_app', args=(app,), context_config=config)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/tg2/tg/configuration/hooks.py", line 109, in notify
INTERNALERROR>     self._call_handler(hook_name, trap_exceptions, func, args, kwargs)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/tg2/tg/configuration/hooks.py", line 33, in _call_handler
INTERNALERROR>     return func(*args, **kwargs)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/config/app_cfg.py", line 103, in setup_configuration
INTERNALERROR>     set_available_permissions(config)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/lib/auth.py", line 693, in set_available_permissions
INTERNALERROR>     all_perms = sa.query(Permission).all()
INTERNALERROR>   File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py", line 2115, in all
INTERNALERROR>     return list(self)
INTERNALERROR>   File "/home/tdescham/repo/contrib/kallithea/kallithea-tg/kallithea/lib/caching_query.py", line 83, in __iter__
INTERNALERROR>     return Query.__iter__(self)
INTERNALERROR>   File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py", line 2227, in __iter__
INTERNALERROR>     return self._execute_and_instances(context)
INTERNALERROR>   File "build/bdist.linux-x86_64/egg/sqlalchemy/orm/query.py", line 2242, in _execute_and_instances
INTERNALERROR>     result = conn.execute(querycontext.statement, self._params)
INTERNALERROR>   File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line 1449, in execute
INTERNALERROR>     params)
INTERNALERROR>   File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line 1584, in _execute_clauseelement
INTERNALERROR>     compiled_sql, distilled_params
INTERNALERROR>   File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line 1698, in _execute_context
INTERNALERROR>     context)
INTERNALERROR>   File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/base.py", line 1691, in _execute_context
INTERNALERROR>     context)
INTERNALERROR>   File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/default.py", line 331, in do_execute
INTERNALERROR>     cursor.execute(statement, parameters)
INTERNALERROR> OperationalError: (OperationalError) no such table: permissions u'SELECT permissions.permission_id AS permissions_permission_id, permissions.permission_name AS permissions_permission_name \nFROM permissions' ()

diff --git a/kallithea/tests/__init__.py b/kallithea/tests/__init__.py
--- a/kallithea/tests/__init__.py
+++ b/kallithea/tests/__init__.py
@@ -33,18 +33,18 @@ from os.path import join as jn
 
 from tempfile import _RandomNameSequence
 
-import pylons
-import pylons.test
+#import pylons
+#import pylons.test
 from tg import config, url
-from pylons.i18n.translation import _get_translator
-from pylons.util import ContextObj
+#from pylons.i18n.translation import _get_translator
+#from pylons.util import ContextObj
 
 from routes.util import URLGenerator
 from webtest import TestApp
 import pytest
 
 from kallithea.lib.compat import unittest
-from kallithea import is_windows
+from kallithea import is_windows, model
 from kallithea.model.db import Notification, User, UserNotification
 from kallithea.model.meta import Session
 from kallithea.tests.parameterized import parameterized
@@ -148,16 +148,26 @@ class NullHandler(logging.Handler):
     def emit(self, record):
         pass
 
+def load_app(name='main'):
+    """Load the test application."""
+    return TestApp(loadapp('config:test.ini#%s' % name, relative_to=getcwd()))
+
+def setup_db():
+    """Create the database schema (not needed when you run setup_app)."""
+    engine = config['tg.app_globals'].sa_engine
+    model.init_model(engine)
+    model.metadata.create_all(engine)
+
 def init_stack(config=None):
-    if not config:
-        config = pylons.test.pylonsapp.config
-    url._push_object(URLGenerator(config['routes.map'], environ))
-    pylons.app_globals._push_object(config['pylons.app_globals'])
-    pylons.config._push_object(config)
-    pylons.tmpl_context._push_object(ContextObj())
-    # Initialize a translator for tests that utilize i18n
-    translator = _get_translator(pylons.config.get('lang'))
-    pylons.translator._push_object(translator)
+    #if not config:
+    #    config = pylons.test.pylonsapp.config
+    #url._push_object(URLGenerator(config['routes.map'], environ))
+    #pylons.app_globals._push_object(config['pylons.app_globals'])
+    #pylons.config._push_object(config)
+    #pylons.tmpl_context._push_object(ContextObj())
+    ## Initialize a translator for tests that utilize i18n
+    #translator = _get_translator(pylons.config.get('lang'))
+    #pylons.translator._push_object(translator)
     h = NullHandler()
     logging.getLogger("kallithea").addHandler(h)
 
@@ -174,8 +184,8 @@ class BaseTestCase(unittest.TestCase):
     """Unittest-style base test case. Deprecated in favor of pytest style."""
 
     def __init__(self, *args, **kwargs):
-        self.wsgiapp = pylons.test.pylonsapp
-        init_stack(self.wsgiapp.config)
+        #self.wsgiapp = pylons.test.pylonsapp
+        #init_stack(self.wsgiapp.config)
         unittest.TestCase.__init__(self, *args, **kwargs)
 
 class BaseTestController(object):
@@ -184,7 +194,9 @@ class BaseTestController(object):
     # Note: pytest base classes cannot have an __init__ method
 
     def init(self):
-        self.app = TestApp(self.wsgiapp)
+        #self.app = TestApp(self.wsgiapp)
+        self.app = load_app()
+        setup_db()
         self.maxDiff = None
         self.index_location = config['app_conf']['index_dir']
 
@@ -247,8 +259,8 @@ class TestControllerPytest(BaseTestContr
 
     @pytest.fixture(autouse=True)
     def app_fixture(self):
-        self.wsgiapp = pylons.test.pylonsapp
-        init_stack(self.wsgiapp.config)
+        #self.wsgiapp = pylons.test.pylonsapp
+        #init_stack(self.wsgiapp.config)
         self.init()
         return self.app
 
diff --git a/kallithea/tests/conftest.py b/kallithea/tests/conftest.py
--- a/kallithea/tests/conftest.py
+++ b/kallithea/tests/conftest.py
@@ -7,6 +7,8 @@ from paste.deploy import loadapp
 import pylons.test
 from pylons.i18n.translation import _get_translator
 
+import kallithea.tests
+
 
 def pytest_configure():
     path = os.getcwd()
@@ -14,9 +16,9 @@ def pytest_configure():
     pkg_resources.working_set.add_entry(path)
 
     # Disable INFO logging of test database creation, restore with NOTSET
-    logging.disable(logging.INFO)
-    pylons.test.pylonsapp = loadapp('config:kallithea/tests/test.ini', relative_to=path)
-    logging.disable(logging.NOTSET)
+    #logging.disable(logging.INFO)
+    kallithea.tests.pylonsapp = loadapp('config:kallithea/tests/test.ini', relative_to=path)
+    #logging.disable(logging.NOTSET)
 
     # Setup the config and app_globals, only works if we can get
     # to the config object
diff --git a/kallithea/tests/other/test_dummy.py b/kallithea/tests/other/test_dummy.py
new file mode 100644
--- /dev/null
+++ b/kallithea/tests/other/test_dummy.py
@@ -0,0 +1,9 @@
+from kallithea.tests import TestControllerPytest
+
+class TestDummy(TestControllerPytest):
+
+    def test_success(self):
+        assert True
+
+    def test_failure(self):
+        assert False


More information about the kallithea-general mailing list