Author: Armin Rigo <[email protected]>
Branch:
Changeset: r71127:5fc41bfef56f
Date: 2014-05-01 09:31 +0200
http://bitbucket.org/pypy/pypy/changeset/5fc41bfef56f/
Log: Test and fix (according to -A)
diff --git a/pypy/module/_lsprof/interp_lsprof.py
b/pypy/module/_lsprof/interp_lsprof.py
--- a/pypy/module/_lsprof/interp_lsprof.py
+++ b/pypy/module/_lsprof/interp_lsprof.py
@@ -204,20 +204,20 @@
name = '?'
if class_name is None:
class_name = w_type.getname(space) # if the rest doesn't work
- return "{method '%s' of '%s' objects}" % (name, class_name)
+ return "<method '%s' of '%s' objects>" % (name, class_name)
def create_spec_for_function(space, w_func):
if w_func.w_module is not None:
module = space.str_w(w_func.w_module)
if module != '__builtin__':
- return '{%s.%s}' % (module, w_func.name)
- return '{%s}' % w_func.name
+ return '<%s.%s>' % (module, w_func.name)
+ return '<%s>' % w_func.name
def create_spec_for_object(space, w_obj):
class_name = space.type(w_obj).getname(space)
- return "{'%s' object}" % (class_name,)
+ return "<'%s' object>" % (class_name,)
def create_spec(space, w_arg):
diff --git a/pypy/module/_lsprof/test/test_cprofile.py
b/pypy/module/_lsprof/test/test_cprofile.py
--- a/pypy/module/_lsprof/test/test_cprofile.py
+++ b/pypy/module/_lsprof/test/test_cprofile.py
@@ -11,6 +11,22 @@
import _lsprof
assert repr(_lsprof.Profiler) == "<type '_lsprof.Profiler'>"
+ def test_builtins(self):
+ import _lsprof
+ prof = _lsprof.Profiler()
+ lst = []
+ prof.enable()
+ lst.append(len(lst))
+ prof.disable()
+ stats = prof.getstats()
+ expected = (
+ "<len>",
+ "<method 'append' of 'list' objects>",
+ "<method 'disable' of '_lsprof.Profiler' objects>",
+ )
+ for entry in stats:
+ assert entry.code in expected
+
def test_direct(self):
import _lsprof
def getticks():
@@ -37,10 +53,8 @@
stats = prof.getstats()
entries = {}
for entry in stats:
- if not hasattr(entry.code, 'co_name'):
- print entry.code
- else:
- entries[entry.code.co_name] = entry
+ assert hasattr(entry.code, 'co_name')
+ entries[entry.code.co_name] = entry
efoo = entries['foo']
assert efoo.callcount == 2
assert efoo.reccallcount == 1
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit