[py-svn] r36939 - in py/dist/py/apigen/tracer: . testing
guido at codespeak.net
guido at codespeak.net
Thu Jan 18 15:04:45 CET 2007
Author: guido
Date: Thu Jan 18 15:04:44 2007
New Revision: 36939
Modified:
py/dist/py/apigen/tracer/description.py
py/dist/py/apigen/tracer/testing/test_docgen.py
Log:
Isolated some code that checks whether a variable is private/protected.
Modified: py/dist/py/apigen/tracer/description.py
==============================================================================
--- py/dist/py/apigen/tracer/description.py (original)
+++ py/dist/py/apigen/tracer/description.py Thu Jan 18 15:04:44 2007
@@ -8,6 +8,9 @@
MAX_CALL_SITES = 20
+def is_private(name):
+ return name.startswith('_') and not name.startswith('__')
+
class CallFrame(object):
def __init__(self, frame):
self.filename = frame.code.raw.co_filename
@@ -256,8 +259,7 @@
def getfields(self):
# return fields of values that has been used
- l = [i for i, v in self.fields.iteritems() if (not i.startswith('_')
- or i.startswith('__'))]
+ l = [i for i, v in self.fields.iteritems() if not is_private(i)]
return l
def getbases(self):
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 Jan 18 15:04:44 2007
@@ -334,8 +334,8 @@
assert len(ds.descs['C'].fields['meth'].call_sites) == 1
return ds
-def test_private_methods():
- py.test.skip('XXX borken')
+def test_is_private():
+ # XXX implicit test, but so are the rest :|
class Foo(object):
def foo(self):
pass
@@ -358,6 +358,6 @@
f.trigger__foo()
f.__foo__()
t.end_tracing()
- assert sorted(ds.descs['Foo'].fields.keys()) == ['__foo__', '_foo', 'foo',
- 'trigger_foo']
+ assert sorted(ds.descs['Foo'].getfields()) == ['__foo__', 'foo',
+ 'trigger__foo']
More information about the pytest-commit
mailing list