py3k test fixes. Closes #109988

authorSylvain Th?nault <sylvain.thenault@logilab.fr>
changesetf64b5ca176ea
branchdefault
phasepublic
hiddenno
parent revision#e3b8e6d27ea0 backport stable
child revision#4917453ba4ab [test] fix unittest2 deprecation warnings
files modified by this revision
setup.py
test/unittest_inference.py
test/unittest_nodes.py
test/unittest_scoped_nodes.py
# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1353055423 -3600
# Fri Nov 16 09:43:43 2012 +0100
# Node ID f64b5ca176ea0f26f4a8db1e1a1d2ad378fdbafe
# Parent e3b8e6d27ea07de61ac2e0f7d20b27944eb60fae
py3k test fixes. Closes #109988

diff --git a/setup.py b/setup.py
@@ -48,11 +48,11 @@
1  sys.modules.pop('__pkginfo__', None)
2  # import optional features
3  __pkginfo__ = __import__("__pkginfo__")
4  # import required features
5  from __pkginfo__ import modname, version, license, description, \
6 -     web, author, author_email
7 +    web, author, author_email
8 
9  distname = getattr(__pkginfo__, 'distname', modname)
10  scripts = getattr(__pkginfo__, 'scripts', [])
11  data_files = getattr(__pkginfo__, 'data_files', None)
12  subpackage_of = getattr(__pkginfo__, 'subpackage_of', None)
@@ -135,11 +135,15 @@
13              basedir = os.path.join(self.build_lib, base)
14              for directory in include_dirs:
15                  dest = join(basedir, directory)
16                  shutil.rmtree(dest, ignore_errors=True)
17                  shutil.copytree(directory, dest)
18 -
19 +                if sys.version_info >= (3, 0):
20 +                    # process manually python file in include_dirs (test data)
21 +                    from subprocess import check_call
22 +                    print('running 2to3 on', dest) # parens are NOT optional here for py3k compat
23 +                    check_call(['2to3', '-wn', dest])
24 
25  def install(**kwargs):
26      """setup entry point"""
27      if USE_SETUPTOOLS:
28          if '--force-manifest' in sys.argv:
diff --git a/test/unittest_inference.py b/test/unittest_inference.py
@@ -1,7 +1,7 @@
29 -# copyright 2003-2010 Sylvain Thenault, all rights reserved.
30 -# contact mailto:thenault@gmail.com
31 +# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
32 +# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
33  #
34  # This file is part of logilab-astng.
35  #
36  # logilab-astng is free software: you can redistribute it and/or modify it
37  # under the terms of the GNU Lesser General Public License as published by the
@@ -935,11 +935,11 @@
38          astng = builder.file_build(fname, 'absimp.string')
39          self.failUnless(astng.absolute_import_activated(), True)
40          infered = get_name_node(astng, 'string').infer().next()
41          self.assertIsInstance(infered, nodes.Module)
42          self.assertEqual(infered.name, 'string')
43 -        self.failUnless('lower' in infered.locals)
44 +        self.failUnless('ascii_letters' in infered.locals)
45 
46      def test_mechanize_open(self):
47          try:
48              import mechanize
49          except ImportError:
diff --git a/test/unittest_nodes.py b/test/unittest_nodes.py
@@ -1,13 +1,7 @@
50 -# This program is free software; you can redistribute it and/or modify it under
51 -# the terms of the GNU Lesser General Public License as published by the Free Software
52 -# Foundation; either version 2 of the License, or (at your option) any later
53 -# version.
54 -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
55 +# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
56  # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
57 -# copyright 2003-2010 Sylvain Thenault, all rights reserved.
58 -# contact mailto:thenault@gmail.com
59  #
60  # This file is part of logilab-astng.
61  #
62  # logilab-astng is free software: you can redistribute it and/or modify it
63  # under the terms of the GNU Lesser General Public License as published by the
@@ -19,18 +13,10 @@
64  # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
65  # for more details.
66  #
67  # You should have received a copy of the GNU Lesser General Public License along
68  # with logilab-astng. If not, see <http://www.gnu.org/licenses/>.
69 -
70 -# This program is distributed in the hope that it will be useful, but WITHOUT
71 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
72 -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
73 -
74 -# You should have received a copy of the GNU Lesser General Public License along with
75 -# this program; if not, write to the Free Software Foundation, Inc.,
76 -# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
77  """tests for specific behaviour of astng nodes
78  """
79  import sys
80 
81  from logilab.common import testlib
diff --git a/test/unittest_scoped_nodes.py b/test/unittest_scoped_nodes.py
@@ -1,9 +1,7 @@
82 -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
83 +# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
84  # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
85 -# copyright 2003-2010 Sylvain Thenault, all rights reserved.
86 -# contact mailto:thenault@gmail.com
87  #
88  # This file is part of logilab-astng.
89  #
90  # logilab-astng is free software: you can redistribute it and/or modify it
91  # under the terms of the GNU Lesser General Public License as published by the
@@ -620,11 +618,11 @@
92      def test_function_with_decorator_lineno(self):
93          data = '''
94  @f(a=2,
95     b=3)
96  def g1(x):
97 -    print x
98 +    print(x)
99 
100  @f(a=2,
101     b=3)
102  def g2():
103      pass