[Python-modules-commits] [fparser] 09/09: remaining known py3 changes

Alastair McKinstry mckinstry at moszumanska.debian.org
Fri Jul 28 10:45:32 UTC 2017


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch dev-python3
in repository fparser.

commit 8611f9281574eae6b5398711044f5f0b9ef1ff88
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Tue Jul 25 21:19:26 2017 +0100

    remaining known py3 changes
---
 src/fparser/Fortran2003.py            | 22 ++++++------
 src/fparser/base_classes.py           | 18 ++++------
 src/fparser/scripts/f2003.py          | 10 +++---
 src/fparser/tests/test_Fortran2003.py | 63 ++++++++++++++++++-----------------
 src/fparser/tests/test_api.py         |  8 ++---
 src/fparser/tests/test_issue7.py      | 42 +++++++++++------------
 src/fparser/tests/test_mod_private.py |  6 ++--
 src/fparser/tests/test_parser.py      |  2 +-
 src/fparser/tests/test_select.py      | 22 ++++++------
 src/fparser/tests/test_utils.py       | 12 +++----
 10 files changed, 101 insertions(+), 104 deletions(-)

diff --git a/src/fparser/Fortran2003.py b/src/fparser/Fortran2003.py
index 660d266..daf3165 100644
--- a/src/fparser/Fortran2003.py
+++ b/src/fparser/Fortran2003.py
@@ -4352,7 +4352,7 @@ class Forall_Triplet_Spec(Base): # R755
         if i==-1: return
         n = Index_Name(repmap(line[:i].rstrip()))
         line = line[i+1:].lstrip()
-        s = map(lambda s: repmap(s.strip()), line.split(':'))
+        s = [repmap(s.strip()) for s in  line.split(':')]
         if len(s)==2:
             return n, Subscript(s[0]), Subscript(s[1]), None
         if len(s)==3:
@@ -5017,7 +5017,7 @@ class Loop_Control(Base): # R830
         var,rhs = line.split('=')
         rhs = [s.strip() for s in rhs.lstrip().split(',')]
         if not 2<=len(rhs)<=3: return
-        return Variable(repmap(var.rstrip())),map(Scalar_Int_Expr, map(repmap,rhs))
+        return Variable(repmap(var.rstrip())),list(map(Scalar_Int_Expr, list(map(repmap,rhs))))
     match = staticmethod(match)
     def tostr(self):
         if len(self.items)==1: return ', WHILE (%s)' % (self.items[0])
@@ -7461,29 +7461,29 @@ for clsname in _names:
             _names.append(n)
             n = n[:-5]
             #print 'Generating %s_List' % (n)
-            exec '''\
+            exec('''\
 class %s_List(SequenceBase):
     subclass_names = [\'%s\']
     use_names = []
     def match(string): return SequenceBase.match(r\',\', %s, string)
     match = staticmethod(match)
-''' % (n, n, n)
+''' % (n, n, n))
         elif n.endswith('_Name'):
             _names.append(n)
             n = n[:-5]
             #print 'Generating %s_Name' % (n)
-            exec '''\
+            exec ('''\
 class %s_Name(Base):
     subclass_names = [\'Name\']
-''' % (n)
+''' % (n))
         elif n.startswith('Scalar_'):
             _names.append(n)
             n = n[7:]
             #print 'Generating Scalar_%s' % (n)
-            exec '''\
+            exec ('''\
 class Scalar_%s(Base):
     subclass_names = [\'%s\']
-''' % (n,n)
+''' % (n,n))
 
 
 __autodoc__ = []
@@ -7517,7 +7517,7 @@ if 1: # Optimize subclass tree:
                     l.append(n1)
         return l
 
-    for cls in Base_classes.values():
+    for cls in list(Base_classes.values()):
         if not hasattr(cls, 'subclass_names'): continue
         opt_subclass_names = []
         for n in cls.subclass_names:
@@ -7531,7 +7531,7 @@ if 1: # Optimize subclass tree:
 
 
 # Initialize Base.subclasses dictionary:
-for clsname, cls in Base_classes.items():
+for clsname, cls in list(Base_classes.items()):
     subclass_names = getattr(cls, 'subclass_names', None)
     if subclass_names is None:
         logger.debug('%s class is missing subclass_names list' % (clsname))
@@ -7549,7 +7549,7 @@ for clsname, cls in Base_classes.items():
             # print '%s not implemented needed by %s' % (n,clsname)
 
 if 1:
-    for cls in Base_classes.values():
+    for cls in list(Base_classes.values()):
         subclasses = Base.subclasses.get(cls.__name__,[])
         subclasses_names = [c.__name__ for c in subclasses]
         subclass_names = getattr(cls,'subclass_names', [])
diff --git a/src/fparser/base_classes.py b/src/fparser/base_classes.py
index d4f97c5..6d40164 100644
--- a/src/fparser/base_classes.py
+++ b/src/fparser/base_classes.py
@@ -141,7 +141,7 @@ class AttributeHolder(object):
                 if isinstance(v,list):
                     l.append(ttab + '%s=<%s-list>' % (k,len(v)))
                 elif isinstance(v,dict):
-                    l.append(ttab + '%s=<dict with keys %s>' % (k,v.keys()))
+                    l.append(ttab + '%s=<dict with keys %s>' % (k,list(v.keys())))
                 else:
                     l.append(ttab + '%s=<%s>' % (k,type(v)))
         return '\n'.join(l)
@@ -159,7 +159,7 @@ def get_base_classes(cls):
         bases += get_base_classes(c)
     return bases + cls.__bases__ + (cls,)
 
-class Variable(object):
+class Variable(object, metaclass=classes):
     """
     Variable instance has attributes:
       name
@@ -170,8 +170,6 @@ class Variable(object):
       parent - Statement instances defining the variable
     """
 
-    __metaclass__ = classes
-    
     def __init__(self, parent, name):
         self.parent = parent
         self.parents = [parent]
@@ -228,7 +226,7 @@ class Variable(object):
         return self.typedecl
 
     def add_parent(self, parent):
-        if id(parent) not in map(id, self.parents):
+        if id(parent) not in list(map(id, self.parents)):
             self.parents.append(parent)
         self.parent = parent
         return
@@ -484,18 +482,16 @@ class Variable(object):
     def info(self, message):
         return self.parent.info(message)
 
-class ProgramBlock(object):
-
-    __metaclass__ = classes
-
-class Statement(object):
+class ProgramBlock(object, metaclass=classes):
+    pass
+    
+class Statement(object, metaclass=classes):
     """
     Statement instance has attributes:
       parent  - Parent BeginStatement or FortranParser instance
       item    - Line instance containing the statement line
       isvalid - boolean, when False, the Statement instance will be ignored
     """
-    __metaclass__ = classes
 
     modes = ['free','fix','f77','pyf']
     _repr_attr_names = []
diff --git a/src/fparser/scripts/f2003.py b/src/fparser/scripts/f2003.py
index 406c9b5..02aff8b 100644
--- a/src/fparser/scripts/f2003.py
+++ b/src/fparser/scripts/f2003.py
@@ -82,11 +82,11 @@ def runner (parser, options, args):
             reader.set_mode_from_str(options.mode)
         try:
             program = Fortran2003.Program(reader)
-            print program
-        except Fortran2003.NoMatchError, msg:
-            print 'parsing %r failed at %s' % (filename, reader.fifo_item[-1])
-            print 'started at %s' % (reader.fifo_item[0])
-            print 'quiting'
+            print (program)
+        except Fortran2003.NoMatchError as msg:
+            print ('parsing %r failed at %s' % (filename, reader.fifo_item[-1]))
+            print ('started at %s' % (reader.fifo_item[0]))
+            print ('quiting')
             return
 
 def main ():
diff --git a/src/fparser/tests/test_Fortran2003.py b/src/fparser/tests/test_Fortran2003.py
index 3788980..c4b0425 100644
--- a/src/fparser/tests/test_Fortran2003.py
+++ b/src/fparser/tests/test_Fortran2003.py
@@ -62,6 +62,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 # DAMAGE.
 
+from __future__ import print_function
 from fparser.Fortran2003 import *
 from fparser.api import get_reader
 
@@ -1729,15 +1730,15 @@ def test_Parenthesis(): # R701.h
         assert_equal(str(a),'(a + (a + c))')
 
         obj  = cls('("a"+"c")')
-        assert isinstance(obj, cls), `obj`
+        assert isinstance(obj, cls), repr(obj)
         assert str(obj) == '("a" + "c")'
 
         obj  = cls('("a"+")")')
-        assert isinstance(obj, cls), `obj`
+        assert isinstance(obj, cls), repr(obj)
         assert str(obj) == '("a" + ")")'
 
         obj  = cls('''(')'+")")''')
-        assert isinstance(obj, cls), `obj`
+        assert isinstance(obj, cls), repr(obj)
         assert str(obj) == '''(')' + ")")'''
 
         with pytest.raises(NoMatchError) as excinfo:
@@ -2112,7 +2113,7 @@ def test_Where_Construct(): # R745
     end where n
 '''))
     assert isinstance(a,cls),repr(a)
-    print str(a)
+    print (str(a))
     assert (str(a) ==
                  'n:WHERE (cond1)\nELSEWHERE(cond2) n\nELSEWHERE n\n'
                  'END WHERE n')
@@ -2123,7 +2124,7 @@ def test_Where_Construct(): # R745
     else where n
     end where n
 '''))
-    print str(a)
+    print (str(a))
     assert (str(a) ==
             'n:WHERE (me(:) == "hello")\nELSEWHERE(me(:) == "goodbye") n\n'
             'ELSEWHERE n\n'
@@ -2430,7 +2431,7 @@ def test_Block_Label_Do_Construct(): # R826_1
  12   continue
     '''))
     assert_equal(str(a),'DO 12\n  DO 13\n    a = 1\n13 CONTINUE\n12 CONTINUE')
-    assert len(a.content)==3,`len(a.content)`
+    assert len(a.content)==3,repr(len(a.content))
     assert_equal(str(a.content[1]), 'DO 13\n  a = 1\n13 CONTINUE')
 
 def test_Block_Nonlabel_Do_Construct(): # # R826_2
@@ -2765,26 +2766,26 @@ def test_Inquire_Spec(): # R930
 def test_Format_Stmt(): # R1001
     cls = Format_Stmt
     a = cls('format (3f9.4)')
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),'FORMAT(3F9.4)')
     a = cls("format (' ',3f9.4)")
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),"FORMAT(' ', 3F9.4)")
 
     a = cls('format(i6,f12.6,2x,f12.6)')
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),'FORMAT(I6, F12.6, 2X, F12.6)')
 
     a = cls("format(' Enter smth',$)")
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),"FORMAT(' Enter smth', $)")
 
     a = cls("format(/'a' /'b')")
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),"FORMAT(/, 'a', /, 'b')")
 
     a = cls("format('a:':' b')")
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),"FORMAT('a:', :, ' b')")
 
     return
@@ -2794,25 +2795,25 @@ def test_Format_Stmt(): # R1001
 def test_Format_Specification(): # R1002
     cls = Format_Specification
     a = cls('(3f9.4, 2f8.1)')
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),'(3F9.4, 2F8.1)')
 
     a = cls("(' ', 2f8.1)")
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),"(' ', 2F8.1)")
     
 def test_Format_Item(): # R1003
     cls = Format_Item
     a = cls('3f9.4')
-    assert isinstance(a, cls),`type(a)`
+    assert isinstance(a, cls),repr(type(a))
     assert_equal(str(a),'3F9.4')
 
     a = cls("' '")
-    assert isinstance(a, Char_Literal_Constant),`type(a)`
+    assert isinstance(a, Char_Literal_Constant),repr(type(a))
     assert_equal(str(a),"' '")
 
     a = cls('i4/')
-    assert isinstance(a, Format_Item_C1002),`type(a)`
+    assert isinstance(a, Format_Item_C1002),repr(type(a))
     assert_equal(str(a),'I4, /')
 
     a = cls('3f12.6/')
@@ -2900,15 +2901,15 @@ def test_Edit_Desc():
 def test_Format_Item_List():
     cls = Format_Item_List
     a = cls('3f9.4')
-    assert isinstance(a, Format_Item),`type(a)`
+    assert isinstance(a, Format_Item),repr(type(a))
     assert_equal(str(a),'3F9.4')
 
     a = cls('3f9.4, 2f8.1')
-    assert isinstance(a, Format_Item_List),`type(a)`
+    assert isinstance(a, Format_Item_List),repr(type(a))
     assert_equal(str(a),'3F9.4, 2F8.1')
 
     a = cls("' ', 2f8.1")
-    assert isinstance(a, Format_Item_List),`type(a)`
+    assert isinstance(a, Format_Item_List),repr(type(a))
     assert_equal(str(a),"' ', 2F8.1")
 
     a = cls("' ', ' '")
@@ -3238,7 +3239,7 @@ def test_Proc_Attr_Spec(): # R1213
     assert_equal(str(a),'SAVE')
 
     a = cls('private')
-    assert isinstance(a, Access_Spec),`type(a)`
+    assert isinstance(a, Access_Spec),repr(type(a))
     assert_equal(str(a),'PRIVATE')
 
     a = cls('bind(c)')
@@ -3253,7 +3254,7 @@ def test_Proc_Decl(): # R1214
     assert_equal(str(a),'a => NULL')
 
     a = cls('a')
-    assert isinstance(a, Name),`type(a)`
+    assert isinstance(a, Name),repr(type(a))
     assert_equal(str(a),'a')
 
 def test_Intrinsic_Stmt(): # R1216
@@ -3606,20 +3607,20 @@ if 0:
         total_needs += 1
         if match is None:
             if test_cls is None:
-                print 'Needs tests:', clsname
-                print 'Needs match implementation:', clsname
+                print ('Needs tests:', clsname)
+                print ('Needs match implementation:', clsname)
                 nof_needed_tests += 1
                 nof_needed_match += 1
             else:
-                print 'Needs match implementation:', clsname
+                print ('Needs match implementation:', clsname)
                 nof_needed_match += 1
         else:
             if test_cls is None:
-                print 'Needs tests:', clsname
+                print ('Needs tests:', clsname)
                 nof_needed_tests += 1
         continue
-    print '-----'
-    print 'Nof match implementation needs:',nof_needed_match,'out of',total_needs
-    print 'Nof tests needs:',nof_needed_tests,'out of',total_needs
-    print 'Total number of classes:',total_classes
-    print '-----'
+    print ('-----')
+    print ('Nof match implementation needs:',nof_needed_match,'out of',total_needs)
+    print ('Nof tests needs:',nof_needed_tests,'out of',total_needs)
+    print ('Total number of classes:',total_classes)
+    print ('-----')
diff --git a/src/fparser/tests/test_api.py b/src/fparser/tests/test_api.py
index 55788ef..1f5dd2f 100644
--- a/src/fparser/tests/test_api.py
+++ b/src/fparser/tests/test_api.py
@@ -157,10 +157,10 @@ def test_provides():
     tree = api.parse(source_str, isfree=True, isstrict=False)
     mod5 = tree.a.module['mod5']
     mod6 = tree.a.module['mod6']
-    assert mod5.a.module_provides.keys() == ['fp', 'dummy']
-    assert mod5.a.use_provides.keys() == ['a', 'b', 'e', 'a2', 'b2', 'lgp']
-    assert mod6.a.module_provides.keys() ==  []
-    assert mod6.a.use_provides.keys() ==  ['fp', 'dummy', 'b', 'e', 'qgp', 'a2', 'a', 'b2']
+    assert list(mod5.a.module_provides.keys()) == ['fp', 'dummy']
+    assert list(mod5.a.use_provides.keys()) == ['a', 'b', 'e', 'a2', 'b2', 'lgp']
+    assert list(mod6.a.module_provides.keys()) ==  []
+    assert list(mod6.a.use_provides.keys()) ==  ['fp', 'dummy', 'b', 'e', 'qgp', 'a2', 'a', 'b2']
     assert mod6.a.use_provides['qgp'].name == 'gp'
 
 def test_walk():
diff --git a/src/fparser/tests/test_issue7.py b/src/fparser/tests/test_issue7.py
index 98a424f..738d9ec 100644
--- a/src/fparser/tests/test_issue7.py
+++ b/src/fparser/tests/test_issue7.py
@@ -79,10 +79,10 @@ C
     tree = api.get_reader(source_str, isfree=False, isstrict=False)
     tree = list(tree)
     s, u, c, e = tree[:3]+tree[-1:]
-    assert s.span==(1,1),`s.span`
-    assert u.span==(2,2),`u.span`
-    assert c.span==(3,3),`c.span`
-    assert e.span==(9,9),`e.span`
+    assert s.span==(1,1),repr(s.span)
+    assert u.span==(2,2),repr(u.span)
+    assert c.span==(3,3),repr(c.span)
+    assert e.span==(9,9),repr(e.span)
 
 def test_reproduce_issue_fix77():
     source_str = '''\
@@ -96,9 +96,9 @@ c
     tree = list(tree)
     foo, a, comment, end = tree[:3]+tree[-1:]
     assert foo.span==(1,1)
-    assert a.span==(2,4),`a.span`
-    assert comment.span==(5,5),`comment.span`
-    assert end.span==(5,5),`end.span`
+    assert a.span==(2,4),repr(a.span)
+    assert comment.span==(5,5),repr(comment.span)
+    assert end.span==(5,5),repr(end.span)
 
 def test_reproduce_issue_fix90():
     source_str = '''\
@@ -112,8 +112,8 @@ c 2
     tree = list(tree)
     foo, a, comment,end = tree[:3]+tree[-1:]
     assert foo.span==(1,1)
-    assert a.span==(2,2),`a.span`
-    assert end.span==(5,5),`end.span`
+    assert a.span==(2,2),repr(a.span)
+    assert end.span==(5,5),repr(end.span)
 
     source_str = '''\
       subroutine foo()
@@ -126,8 +126,8 @@ c
     tree = list(tree)
     foo, a, comment,end = tree[:3]+tree[-1:]
     assert foo.span==(1,1)
-    assert a.span==(2,2),`a.span`
-    assert end.span==(5,5),`end.span`
+    assert a.span==(2,2),repr(a.span)
+    assert end.span==(5,5),repr(end.span)
 
     source_str = '''\
       subroutine foo()
@@ -140,9 +140,9 @@ c
     tree = list(tree)
     foo, a, comment, end = tree[:3]+tree[-1:]
     assert foo.span==(1,1)
-    assert a.span==(2,2),`a.span`
+    assert a.span==(2,2),repr(a.span)
     assert comment.span == (3,3)
-    assert end.span==(5,5),`end.span`
+    assert end.span==(5,5),repr(end.span)
 
 def test_comment_cont_fix90():
     source_str = '''\
@@ -157,8 +157,8 @@ c 2
     tree = list(tree)
     foo, a, comment, end = tree[:3]+tree[-1:]
     assert foo.span==(1,1)
-    assert a.span==(2,4),`a.span`
-    assert comment.span==(3,3),`comment.span`
+    assert a.span==(2,4),repr(a.span)
+    assert comment.span==(3,3),repr(comment.span)
     assert end.span==(6,6)
 
     source_str = '''\
@@ -173,8 +173,8 @@ c 2
     tree = list(tree)
     foo, a, comment, end = tree[:3]+tree[-1:]
     assert foo.span==(1,1)
-    assert a.span==(2,4),`a.span`
-    assert comment.span==(3,3),`comment.span`
+    assert a.span==(2,4),repr(a.span)
+    assert comment.span==(3,3),repr(comment.span)
     assert end.span==(6,6)
 
     source_str = '''\
@@ -189,8 +189,8 @@ c
     tree = list(tree)
     foo, a, comment, end = tree[:3]+tree[-1:]
     assert foo.span==(1,1)
-    assert a.span==(2,4),`a.span`
-    assert comment.span==(3,3),`comment.span`
+    assert a.span==(2,4),repr(a.span)
+    assert comment.span==(3,3),repr(comment.span)
     assert end.span==(6,6)
 
     source_str = '''\
@@ -206,6 +206,6 @@ c 2
     tree = list(tree)
     foo, ab, comment, end = tree[:3]+tree[-1:]
     assert foo.span==(1,1)
-    assert ab.span==(2,6),`a.span`
-    assert comment.span==(3,3),`comment.span`
+    assert ab.span==(2,6),repr(a.span)
+    assert comment.span==(3,3),repr(comment.span)
     assert end.span==(7,7)
diff --git a/src/fparser/tests/test_mod_private.py b/src/fparser/tests/test_mod_private.py
index d9277f8..0ff9c2f 100644
--- a/src/fparser/tests/test_mod_private.py
+++ b/src/fparser/tests/test_mod_private.py
@@ -74,9 +74,9 @@ end subroutine
 end module mod1
 '''
     mod1 = api.parse(src, isfree=True, isstrict=False).content[0]
-    assert mod1.get_provides() == {}, `mod1.get_provides()`
-    assert mod1.a.variables.keys() == ['i']
-    assert mod1.a.module_subprogram.keys() == ['s1']
+    assert mod1.get_provides() == {}, repr(mod1.get_provides())
+    assert list(mod1.a.variables.keys()) == ['i']
+    assert list(mod1.a.module_subprogram.keys()) == ['s1']
 
 def test_access_spec():
     src = '''\
diff --git a/src/fparser/tests/test_parser.py b/src/fparser/tests/test_parser.py
index ffe983b..ea03ee6 100644
--- a/src/fparser/tests/test_parser.py
+++ b/src/fparser/tests/test_parser.py
@@ -81,7 +81,7 @@ def parse(cls, line, label='', isfree=True, isstrict=False):
         line = label + ' : ' + line
     reader = FortranStringReader(line)
     reader.set_mode(isfree, isstrict)
-    item = reader.next()
+    item = next(reader)
     if not cls.match(item.get_line()):
         raise ValueError('%r does not match %s pattern'%(line, cls.__name__))
     stmt = cls(item, item)
diff --git a/src/fparser/tests/test_select.py b/src/fparser/tests/test_select.py
index 1058395..69a5f00 100644
--- a/src/fparser/tests/test_select.py
+++ b/src/fparser/tests/test_select.py
@@ -66,7 +66,7 @@
 Test fparser support for parsing select-case and select-type blocks
 
 """
-
+from __future__ import print_function
 import pytest
 
 
@@ -79,7 +79,7 @@ import pytest
 def print_wrapper(arg):
     ''' A wrapper that allows us to call print as a function. Used for
     monkeypatching logging calls. '''
-    print arg
+    print (arg)
     return None
 
 
@@ -106,7 +106,7 @@ def test_case_internal_error(monkeypatch, capsys):
     from fparser.readfortran import FortranStringReader
     reader = FortranStringReader('CASE (yes)')
     reader.set_mode(True, False)
-    item = reader.next()
+    item = next(reader)
     stmt = Case(item, item)
     # Monkeypatch our valid Case object so that get_line() now
     # returns something invalid. We have to do it this way
@@ -120,7 +120,7 @@ def test_case_internal_error(monkeypatch, capsys):
     monkeypatch.setattr(stmt, "warning", print_wrapper)
     stmt.process_item()
     output, _ = capsys.readouterr()
-    print output
+    print (output)
     assert "Internal error when parsing CASE statement" in output
 
 
@@ -131,7 +131,7 @@ def test_class_internal_error(monkeypatch, capsys):
     from fparser.readfortran import FortranStringReader
     reader = FortranStringReader('CLASS IS (yes)')
     reader.set_mode(True, False)
-    item = reader.next()
+    item = next(reader)
     stmt = ClassIs(item, item)
     # Monkeypatch our valid Case object so that get_line() now
     # returns something invalid. We have to do it this way
@@ -184,7 +184,7 @@ def test_select_case():
         assert isinstance(statement.content[2], fparser.statements.Case)
         assert isinstance(statement.content[3], fparser.statements.Assignment)
     gen = str(tree)
-    print gen
+    print (gen)
     assert "SELECT CASE ( iflag )" in gen
 
 
@@ -218,7 +218,7 @@ def test_named_select_case():
         assert isinstance(statement.content[2], fparser.statements.Case)
         assert isinstance(statement.content[3], fparser.statements.Assignment)
     gen = str(tree)
-    print gen
+    print (gen)
     assert "incase: SELECT CASE ( iflag )" in gen
 
 
@@ -250,7 +250,7 @@ def test_select_case_brackets():
     assert isinstance(statement.content[2], fparser.statements.Case)
     assert isinstance(statement.content[3], fparser.statements.Assignment)
     gen = str(tree)
-    print gen
+    print (gen)
     assert "SELECT CASE ( iflag(1) )" in gen
 
 
@@ -295,7 +295,7 @@ def test_select_type():
         assert isinstance(statement.content[3], fparser.statements.Assignment)
         assert isinstance(statement.content[4], fparser.statements.ClassIs)
     gen = str(tree)
-    print gen
+    print (gen)
     assert "SELECT TYPE ( an_object )" in gen
     assert "TYPE IS ( some_type )" in gen
     assert "TYPE IS ( some_type(i), some_other_type )" in gen
@@ -338,7 +338,7 @@ def test_type_is_process_item(monkeypatch, capsys):
     monkeypatch.setattr(typeis, "warning", print_wrapper)
     typeis.process_item()
     output, _ = capsys.readouterr()
-    print output
+    print (output)
     assert "expected type-is-construct-name 'not_a_name' but got " in output
 
 
@@ -412,7 +412,7 @@ def test_class_is_process_item(monkeypatch, capsys):
     monkeypatch.setattr(clsis, "warning", print_wrapper)
     clsis.process_item()
     output, _ = capsys.readouterr()
-    print output
+    print (output)
     assert "expected class-construct-name 'not_a_name' but got " in output
 
 
diff --git a/src/fparser/tests/test_utils.py b/src/fparser/tests/test_utils.py
index 07f6b20..3d92551 100644
--- a/src/fparser/tests/test_utils.py
+++ b/src/fparser/tests/test_utils.py
@@ -36,7 +36,7 @@
 Test the various utility functions
 
 """
-
+from __future__ import print_function
 import pytest
 from fparser.utils import split_comma, ParseError
 
@@ -44,12 +44,12 @@ from fparser.utils import split_comma, ParseError
 def test_split_comma():
     ''' Test the split_comma() function '''
     items = split_comma("hello, goodbye")
-    print items
+    print (items)
     assert items[0] == "hello"
     assert items[1] == "goodbye"
     # With trailing and leading white space
     items = split_comma("  hello, goodbye   ")
-    print items
+    print (items)
     assert items[0] == "hello"
     assert items[1] == "goodbye"
     items = split_comma("  ")
@@ -73,19 +73,19 @@ def test_split_comma_exceptions():
 def test_split_bracketed_list():
     ''' Test the splitting of a list bracketed with parentheses '''
     items = split_comma("(well(1), this(is), it)", brackets=("(", ")"))
-    print items
+    print (items)
     assert items[0] == "well(1)"
     assert items[1] == "this(is)"
     # With superfluous white space
     items = split_comma("  (  well(1), this(is), it  )  ",
                         brackets=("(", ")"))
-    print items
+    print (items)
     assert items[0] == "well(1)"
     assert items[1] == "this(is)"
     assert items[2] == "it"
     # Square brackets
     items = split_comma("[well(1), this(is), it]", brackets=("[", "]"))
-    print items
+    print (items)
     assert items[0] == "well(1)"
     assert items[1] == "this(is)"
     assert items[2] == "it"

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/fparser.git



More information about the Python-modules-commits mailing list