/usr/share/pyshared/martian/tests/public_methods_from_class.txt is in python-martian 0.14-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | Consider the following class
>>> class A(object):
... an_attribute = 42
...
... def __init__(self):
... pass # this method is ignored
...
... def __call__(self):
... pass # this method is ignored
...
... def __double_underscored(self):
... pass # this method is ignored
...
... def _single_underscored(self):
... pass # this method is ignored
...
... def should_be_public(self):
... pass # this method is found
...
... def should_also_be_public(self):
... pass # this method is found
...
With martian's ``public_methods_from_class`` helper we can extract all
public methods from this class, in other words, all methods that do
not begin with an underscore:
>>> from martian import util
>>> methods = util.public_methods_from_class(A)
>>> sorted([m.__name__ for m in methods])
['should_also_be_public', 'should_be_public']
|