[test] Fix devtools unittest_i18n when ran without pytest
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 19 May 2016 14:21:21 +0200
changeset 11249 0ff4c02a1871
parent 11248 b288debc6736
child 11250 597f02c5cf5a
[test] Fix devtools unittest_i18n when ran without pytest There is currently some weird error, requiring both to hack cubicweb.__path__ and to stop using load_module_from_name to load the registry. Introduce a dependency on to-be-released version of logilab common integrating fix for https://www.logilab.org/ticket/6085650 Do some extra import cleanups along the way.
cubicweb/__init__.py
cubicweb/cwvreg.py
tox.ini
--- a/cubicweb/__init__.py	Fri Feb 05 14:48:23 2016 +0100
+++ b/cubicweb/__init__.py	Thu May 19 14:21:21 2016 +0200
@@ -20,35 +20,38 @@
 """
 __docformat__ = "restructuredtext en"
 
-# ignore the pygments UserWarnings
+import logging
+import os
+import sys
 import warnings
 import zlib
-warnings.filterwarnings('ignore', category=UserWarning,
-                        message='.*was already imported',
-                        module='.*pygments')
-
-
-from six import PY2, binary_type, text_type
-from six.moves import builtins
-
-CW_SOFTWARE_ROOT = __path__[0]
-
-import sys, os, logging
 if (2, 7) <= sys.version_info < (2, 7, 4):
     # http://bugs.python.org/issue10211
     from StringIO import StringIO as BytesIO
 else:
     from io import BytesIO
 
-from six.moves import cPickle as pickle
+from six import PY2, binary_type, text_type
+from six.moves import builtins, cPickle as pickle
 
 from logilab.common.deprecation import deprecated
 from logilab.common.logging_ext import set_log_methods
 from yams.constraints import BASE_CONVERTERS, BASE_CHECKERS
 
+# ignore the pygments UserWarnings
+warnings.filterwarnings('ignore', category=UserWarning,
+                        message='.*was already imported',
+                        module='.*pygments')
+
 # pre python 2.7.2 safety
 logging.basicConfig()
 
+# this is necessary for i18n devtools test where chdir is done while __path__ is relative, which
+# breaks later imports
+__path__[0] = os.path.abspath(__path__[0])
+CW_SOFTWARE_ROOT = __path__[0]
+
+
 from cubicweb.__pkginfo__ import version as __version__
 
 
--- a/cubicweb/cwvreg.py	Fri Feb 05 14:48:23 2016 +0100
+++ b/cubicweb/cwvreg.py	Thu May 19 14:21:21 2016 +0200
@@ -31,11 +31,9 @@
 from six import text_type, binary_type
 
 from logilab.common.decorators import cached, clear_cache
-from logilab.common.deprecation import deprecated, class_deprecated
+from logilab.common.deprecation import class_deprecated
 from logilab.common.modutils import cleanup_sys_modules
-from logilab.common.registry import (
-    RegistryStore, Registry, obj_registries,
-    ObjectNotFound, RegistryNotFound)
+from logilab.common.registry import RegistryStore, Registry, ObjectNotFound, RegistryNotFound
 
 from rql import RQLHelper
 from yams.constraints import BASE_CONVERTERS
--- a/tox.ini	Fri Feb 05 14:48:23 2016 +0100
+++ b/tox.ini	Thu May 19 14:21:21 2016 +0200
@@ -10,6 +10,7 @@
   /usr/bin/touch
 deps =
   hg+https://hg.logilab.org/master/yams@20b43fb67201#egg=yams
+  hg+https://hg.logilab.org/master/logilab/common@7ebacaa38380#egg=logilab-common
   py34: -e.
   cubicweb: -r{toxinidir}/cubicweb/test/requirements.txt
   devtools: -r{toxinidir}/cubicweb/devtools/test/requirements.txt