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
|
diff --git a/tests.py b/tests.py
index fc2ee7f..d494470 100755
--- a/tests.py
+++ b/tests.py
@@ -11,6 +11,7 @@ import tempfile
import textwrap
import types
import unittest
+import platform
# setuptools imports `imp`, which triggers a DeprecationWarning starting with
# Python 3.4 in the middle of my pristine test suite. But if I do the import
@@ -363,7 +364,7 @@ def doctest_get_new_ids_prints():
========================================================
Type Old_ids Current_ids New_ids Count_Deltas
========================================================
- list ... ... ... +2
+ wt ... ... ... +2
========================================================
"""
@@ -387,7 +388,10 @@ class ByTypeTest(GarbageCollectedMixin, unittest.TestCase):
# 2. the `res` list
# referrers we don't want:
# the ``objects`` list in the now-dead stack frame of objgraph.by_type
- self.assertLessEqual(len(gc.get_referrers(res[0])), 2)
+ if 'pypy' in platform.python_implementation().lower():
+ self.assertLessEqual(len(gc.get_referrers(res[0])), 3)
+ else:
+ self.assertLessEqual(len(gc.get_referrers(res[0])), 2)
class AtAddrsTest(unittest.TestCase):
@@ -439,7 +443,10 @@ class StringRepresentationTest(GarbageCollectedMixin,
obj = MyClass()
with mock.patch.object(obj, 'my_method',
types.MethodType(mock_method, obj)):
- self.assertRegex(objgraph._short_repr(obj.my_method), '<Mock')
+ if 'pypy' in platform.python_implementation().lower():
+ self.assertRegex(objgraph._short_repr(obj.my_method), '<bound method')
+ else:
+ self.assertRegex(objgraph._short_repr(obj.my_method), '<Mock')
def test_short_repr_mocked_name(self):
self.assertRegex(objgraph._short_repr(mock.Mock(__name__=mock.Mock())),
@@ -462,7 +469,10 @@ class StringRepresentationTest(GarbageCollectedMixin,
obj = MyClass()
with mock.patch.object(obj, 'my_method',
types.MethodType(mock_method, obj)):
- self.assertRegex(objgraph._short_repr(obj.my_method), '<Mock')
+ if 'pypy' in platform.python_implementation().lower():
+ self.assertRegex(objgraph._short_repr(obj.my_method), '<bound method')
+ else:
+ self.assertRegex(objgraph._short_repr(obj.my_method), '<Mock')
@skipIf(sys.version_info[0] > 2, "Python 3 has no unbound methods")
def test_short_repr_unbound_method(self):
|