[py-svn] r35153 - in py/dist/py/apigen/tracer: . testing
fijal at codespeak.net
fijal at codespeak.net
Thu Nov 30 12:29:34 CET 2006
Author: fijal
Date: Thu Nov 30 12:29:31 2006
New Revision: 35153
Modified:
py/dist/py/apigen/tracer/description.py
py/dist/py/apigen/tracer/docstorage.py
py/dist/py/apigen/tracer/testing/test_docgen.py
Log:
Cleanup of methods.
Modified: py/dist/py/apigen/tracer/description.py
==============================================================================
--- py/dist/py/apigen/tracer/description.py (original)
+++ py/dist/py/apigen/tracer/description.py Thu Nov 30 12:29:31 2006
@@ -195,7 +195,7 @@
result = self.pyobj
except:
result = self
- return (result, self.pyobj)
+ return result
code = property(getcode)
def consider_call(self, inputcells):
@@ -271,6 +271,16 @@
## def has_code(self, code):
## return self.pyobj.im_func.func_code is code
+ def __hash__(self):
+ return hash((self.code, self.pyobj.im_class))
+
+ def __eq__(self, other):
+ if isinstance(other, tuple):
+ return self.code is other[0] and self.pyobj.im_class is other[1]
+ if isinstance(other, MethodDesc):
+ return self.pyobj is other.pyobj
+ return False
+
def consider_start_locals(self, frame):
# XXX recursion issues?
obj = frame.f_locals[self.pyobj.im_func.func_code.co_varnames[0]]
Modified: py/dist/py/apigen/tracer/docstorage.py
==============================================================================
--- py/dist/py/apigen/tracer/docstorage.py (original)
+++ py/dist/py/apigen/tracer/docstorage.py Thu Nov 30 12:29:31 2006
@@ -45,12 +45,11 @@
desc.consider_exception(exc_class, value)
def find_desc(self, code, locals):
- if code.name == '__init__':
+ try:
# argh, very fragile specialcasing
- key = (code.raw, locals[code.raw.co_varnames[0]].__class__)
- else:
- key = code.raw
- return self.desc_cache.get(key, None)
+ return self.desc_cache[(code.raw, locals[code.raw.co_varnames[0]].__class__)]
+ except (KeyError, IndexError):
+ return self.desc_cache.get(code.raw, None)
#for desc in self.descs.values():
# if desc.has_code(frame.code.raw):
# return desc
Modified: py/dist/py/apigen/tracer/testing/test_docgen.py
==============================================================================
--- py/dist/py/apigen/tracer/testing/test_docgen.py (original)
+++ py/dist/py/apigen/tracer/testing/test_docgen.py Thu Nov 30 12:29:31 2006
@@ -286,7 +286,6 @@
assert dsa.get_method_origin('C.foo') is None
def test_multiple_methods():
- py.test.skip("Failing")
class A(object):
def meth(self):
pass
More information about the pytest-commit
mailing list