On Thursday 09 September 2010 11:37:57 Sylvain Thénault wrote:
> On 09 septembre 11:24, Emile Anclin wrote:
> > I might be missing something, but as far as I can see, if we only
> > care about pylint-3k, it seems to me easier to translate
> > pytest to py3k than to make all tests run with unit2:
> >
> > As I have been told, pytest works with importing unittest2 (hence
> > Python3k's unittest) instead of unittest.
>
> really? Hard to imagine given monkey patches done by pytest/testlib...

Julien Jehannet tested explicitely to run pytest on lgc using unittest2,
so at least the basic functionalities will work. He told me that there 
might be some nasty corner cases though, but for our need I guess that it 
will be enough to run things like :

~/var/pylint $ pytest

and 
~/var/pylint $ pytest test/test_file.py

For further investigation, I think that we need to be able to run pytest 
with py3k:

> > On the other side, I had a quick look at running the tests of lgc
> > with the python2.6 -3 option :
> >
> > $ cd logilab/common
> > $ python2.6 -3 bin/pytest
> >
> > this yields a couple of seemingly simple issues: I would imagine not
> > more than half a day of work.
>
> The point is that time is hard to find,

I meant that we need the time to fix the "-3" Warnings, like the quick 
fixes as attachement. I just had a fast look, and could not find how 
migrating os.path.walk to os.walk. Does anybody know ?

We can ignore all compat warnings I guess. So the last "-3" Warning to fix 
is this one (which I don't know how to solve neither if it is needed 
for our migration):

========================  unittest_table.py  =========================
/home/emile/var/logilab/common/table.py:23: DeprecationWarning: Overriding 
__eq__ blocks inheritance of __hash__ in 3.x
  class Table(object):

Fix those two remaining '-3' is necessary anyway. Then we can test if 
pytest runs py3.x + unittest as good as py3.x + unittest2 

-- 

Emile Anclin <emile.anc...@logilab.fr>
http://www.logilab.fr/   http://www.logilab.org/ 
Informatique scientifique & et gestion de connaissances
diff -r eb6f9d25326a configuration.py
--- a/configuration.py  Thu Sep 09 10:05:25 2010 +0200
+++ b/configuration.py  Thu Sep 09 19:06:16 2010 +0200
@@ -112,6 +112,7 @@
 from ConfigParser import ConfigParser, NoOptionError, NoSectionError, \
      DuplicateSectionError
 from warnings import warn
+import collections
 
 from logilab.common.compat import set, reversed
 from logilab.common.textutils import normalize_text, unquote
@@ -482,7 +483,8 @@
         args, optdict = self.optik_option(provider, opt, optdict)
         option = optikcontainer.add_option(*args, **optdict)
         self._all_options[opt] = provider
-        self._maxlevel = max(self._maxlevel, option.level)
+        # print 'max', type(self._maxlevel), type(option.level)
+        self._maxlevel = max(self._maxlevel, option.level or 0)
 
     def optik_option(self, provider, opt, optdict):
         """get our personal option definition and return a suitable form for
@@ -786,7 +788,7 @@
         if optdict is None:
             optdict = self.get_option_def(opt)
         default = optdict.get('default')
-        if callable(default):
+        if isinstance(default, collections.Callable):
             default = default()
         return default
 
diff -r eb6f9d25326a fileutils.py
--- a/fileutils.py      Thu Sep 09 10:05:25 2010 +0200
+++ b/fileutils.py      Thu Sep 09 19:06:16 2010 +0200
@@ -316,10 +316,7 @@
 
     :warning: at some point this function will probably return an iterator
     """
-    try:
-        readlines = stream.xreadlines
-    except AttributeError:
-        readlines = stream.readlines
+    readlines = stream.readlines
     result = []
     for line in readlines():
         line = line.strip()
diff -r eb6f9d25326a optik_ext.py
--- a/optik_ext.py      Thu Sep 09 10:05:25 2010 +0200
+++ b/optik_ext.py      Thu Sep 09 19:06:16 2010 +0200
@@ -272,9 +272,10 @@
 
 def format_option_help(self, formatter):
     result = []
-    outputlevel = getattr(formatter, 'output_level', 0)
+    outputlevel = getattr(formatter, 'output_level', 0) or 0
     for option in self.option_list:
-        if getattr(option, 'level', 0) <= outputlevel and not option.help is SUPPRESS_HELP:
+        if (getattr(option, 'level', 0) or 0) <= outputlevel \
+          and not option.help is SUPPRESS_HELP:
             result.append(formatter.format_option(option))
     return "".join(result)
 OptionContainer.format_option_help = format_option_help
diff -r eb6f9d25326a test/unittest_shellutils.py
--- a/test/unittest_shellutils.py       Thu Sep 09 10:05:25 2010 +0200
+++ b/test/unittest_shellutils.py       Thu Sep 09 19:06:16 2010 +0200
@@ -127,7 +127,7 @@
         """Test the progress bar for nbops > size"""
         def half(total):
             for counter in range(1,total+1):
-                yield counter / 2
+                yield counter // 2
         self._update_test(40, half(40))
 
     def test_nbops_lt_size(self):
diff -r eb6f9d25326a testlib.py
--- a/testlib.py        Thu Sep 09 10:05:25 2010 +0200
+++ b/testlib.py        Thu Sep 09 19:06:16 2010 +0200
@@ -77,6 +77,9 @@
             pass
     test_support = TestSupport()
 
+import collections
+
+
 # pylint: disable=W0622
 from logilab.common.compat import set, enumerate, any, sorted, InheritableSet
 # pylint: enable-msg=W0622
@@ -615,7 +618,7 @@
                 for attrname in dir(obj):
                     if attrname.startswith(self.testMethodPrefix):
                         attr = getattr(obj, attrname)
-                        if callable(attr):
+                        if isinstance(attr, collections.Callable):
                             methodnames.append(attrname)
                 # keep track of class (obj) for convenience
                 tests[classname] = (obj, methodnames)
@@ -643,7 +646,7 @@
         collected = []
         if len(parts) == 1:
             pattern = parts[0]
-            if callable(getattr(module, pattern, None)
+            if isinstance(getattr(module, pattern, None), collections.Callable
                     )  and pattern not in tests:
                 # consider it as a suite
                 return self.loadTestsFromSuite(module, pattern)

_______________________________________________
Python-Projects mailing list
Python-Projects@lists.logilab.org
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to