Skip to content

Commit

Permalink
use print as a function
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed May 4, 2013
1 parent eb779c9 commit 4c73c3b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/ExtensionClass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
>>> class C(Base):
... def __class_init__(self):
... print 'class init called'
... print self.__name__
... print('class init called')
... print(self.__name__)
... def bar(self):
... return 'bar called'
class init called
Expand Down
42 changes: 19 additions & 23 deletions src/ExtensionClass/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
def print_dict(d):
d = d.items()
d.sort()
print '{%s}' % (', '.join(
print('{%s}' % (', '.join(
[('%r: %r' % (k, v)) for (k, v) in d]
))
)))


def test_mixing():
Expand All @@ -41,8 +41,8 @@ def test_mixing():
>>> class C(Base):
... def __class_init__(self):
... print 'class init called'
... print self.__name__
... print('class init called')
... print(self.__name__)
... def bar(self):
... return 'bar called'
class init called
Expand Down Expand Up @@ -74,28 +74,24 @@ class init called

def test_class_creation_under_stress():
"""
>>> numbers = []
>>> for i in range(100):
... class B(Base):
... print i,
... if i and i%20 == 0:
... print
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
... class B(Base):
... numbers.append(i)
>>> numbers == list(range(100))
True
>>> import gc
>>> x = gc.collect()
"""


def old_test_add():
"""test_add.py from old EC
>>> class foo(Base):
... def __add__(self,other): print 'add called'
... def __add__(self,other):
... print('add called')
>>> foo()+foo()
add called
Expand Down Expand Up @@ -444,9 +440,9 @@ def test_setattr_on_extension_type():
"""
>>> for name in 'x', '_x', 'x_', '__x_y__', '___x__', '__x___', '_x_':
... setattr(Base, name, 1)
... print getattr(Base, name)
... print(getattr(Base, name))
... delattr(Base, name)
... print getattr(Base, name, 0)
... print(getattr(Base, name, 0))
1
0
1
Expand Down Expand Up @@ -477,7 +473,7 @@ def test_setattr_on_extension_type():
>>> try:
... del Base.__foo__
... except (AttributeError, TypeError): # different on pypy
... print 'error'
... print('error')
error
"""

Expand Down Expand Up @@ -641,11 +637,11 @@ def test_avoiding___init__decoy_w_inheritedAttribute():
>>> class B(Base):
... def __init__(self, a, b):
... print '__init__', a, b
... print('__init__ %s %s' % (a, b))
>>> class C(Decoy, B):
... def __init__(self):
... print 'C init'
... print('C init')
... C.inheritedAttribute('__init__')(self, 1, 2)
>>> x = C()
Expand Down Expand Up @@ -731,7 +727,7 @@ def test___of___w_metaclass_instance():
>>> class O(Base):
... def __of__(self, parent):
... print '__of__ called on an O'
... print('__of__ called on an O')
>>> class M(ExtensionClass):
... pass
Expand Down Expand Up @@ -785,7 +781,7 @@ def test___of__set_after_creation():
We define a __of__ method for B after the fact:
>>> def __of__(self, other):
... print '__of__(%r, %r)' % (self, other)
... print('__of__(%r, %r)' % (self, other))
... return self
>>> B.__of__ = __of__
Expand Down Expand Up @@ -830,7 +826,7 @@ def test_Basic_gc():
...
>>> class C2(Base):
... def __del__(self):
... print 'removed'
... print('removed')
...
>>> a=C1()
>>> a.b = C1()
Expand Down
2 changes: 1 addition & 1 deletion src/MethodObject/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def test_methodobject():
>>> class foo(Method):
... def __call__(self, ob, *args, **kw):
... print 'called', ob, args, kw
... print('called %s %s %s' % (ob, args, kw))
>>> class bar(Base):
... def __repr__(self):
Expand Down

0 comments on commit 4c73c3b

Please sign in to comment.