Turbogears2 migration: tests: "cannot import name meta"

Thomas De Schampheleire patrickdepinguin at gmail.com
Sun Sep 25 12:51:56 UTC 2016


On Sun, Sep 25, 2016 at 12:17 AM, Mads Kiilerich <mads at kiilerich.com> wrote:
> On 09/23/2016 09:42 PM, Thomas De Schampheleire wrote:
>>
>> After rebasing the tg2 branch onto recent Kallithea default, more
>> particularly onto something containing this commit:
>>
>> o  6613 8d98924c58b1 default  2016-09-18 Thomas De Schampheleire
>> tests: add as little code as possible in __init__.py
>>
>> I can no longer successfully start the test suite.
>> I get an import error: "cannot import name meta", which refers to some
>> import of kallithea.model.meta.
>
>
> The error goes like:
>
> E     File "/home/madski/kallithea-tg2/kallithea/tests/conftest.py", line
> 12, in <module>
> E       from kallithea.model.user import UserModel
> E     File "/home/madski/kallithea-tg2/kallithea/model/__init__.py", line
> 48, in <module>
> E       from kallithea.model import meta
> E     File "/home/madski/kallithea-tg2/kallithea/model/meta.py", line 21, in
> <module>
> E       from kallithea.lib import caching_query
> E     File "/home/madski/kallithea-tg2/kallithea/lib/__init__.py", line 27,
> in <module>
> E       from . import helpers
> E     File "/home/madski/kallithea-tg2/kallithea/lib/helpers.py", line 56,
> in <module>
> E       from kallithea.lib.utils import repo_name_slug, get_custom_lexer
> E     File "/home/madski/kallithea-tg2/kallithea/lib/utils.py", line 50, in
> <module>
> E       from kallithea.model import meta
>
> So again, we have a recursive dependency. Random changes can influence
> whether that works or not.
>
> Removing more imports from __init__ would be a good start ... though not
> necessarily sufficient to remove recursive imports.
>
> A stupid workaround (and some fixes to merge conflicts):
>
> diff --git a/kallithea/tests/conftest.py b/kallithea/tests/conftest.py
> --- a/kallithea/tests/conftest.py
> +++ b/kallithea/tests/conftest.py
> @@ -11,2 +11,3 @@ from tg.util.webtest import test_context
>  import pytest
> +import kallithea.lib.helpers # HACK to workaround recursive imports ...
>  from kallithea.model.user import UserModel
> diff --git a/kallithea/config/app_cfg.py b/kallithea/config/app_cfg.py
> --- a/kallithea/config/app_cfg.py
> +++ b/kallithea/config/app_cfg.py
> @@ -128,3 +128,3 @@ def setup_configuration(app):
>          from kallithea.lib.utils import create_test_env, create_test_index
> -        from kallithea.tests import TESTS_TMP_PATH
> +        from kallithea.tests.base import TESTS_TMP_PATH
>          #set KALLITHEA_NO_TMP_PATH=1 to disable re-creating the database
> and
> @@ -137,4 +137,2 @@ def setup_configuration(app):
>
> -    DbManage.check_waitress()
> -
>      set_available_permissions(config)
>

I committed this workaround under your name and pushed it together
with my rebase and commit cleanup to the kallithea-tg repo, tip commit
is now 6ede70d
(https://bitbucket.org/_amol_/kallithea-tg/commits/all)


More information about the kallithea-general mailing list