本文整理汇总了Python中twisted.python.reflect.prefixedMethods函数的典型用法代码示例。如果您正苦于以下问题:Python prefixedMethods函数的具体用法?Python prefixedMethods怎么用?Python prefixedMethods使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prefixedMethods函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getPersonCommands
def getPersonCommands(self):
"""finds person commands
these commands are methods on me that start with imperson_; they are
called with no arguments
"""
return prefixedMethods(self, "imperson_")
示例2: getGroupCommands
def getGroupCommands(self):
"""finds group commands
these commands are methods on me that start with imgroup_; they are
called with no arguments
"""
return prefixedMethods(self, "imgroup_")
示例3: test_prefix
def test_prefix(self):
"""
If a prefix is given, L{prefixedMethods} returns only methods named
with that prefix.
"""
x = Separate()
output = prefixedMethods(x, 'good_')
self.assertEqual([x.good_method], output)
示例4: test_onlyObject
def test_onlyObject(self):
"""
L{prefixedMethods} returns a list of the methods discovered on an
object.
"""
x = Base()
output = prefixedMethods(x)
self.assertEqual([x.method], output)
示例5: getTargetCommands
def getTargetCommands(self, target):
"""finds group commands
these commands are methods on me that start with imgroup_; they are
called with a user present within this room as an argument
you may want to override this in your group in order to filter for
appropriate commands on the given user
"""
return prefixedMethods(self, "imtarget_")
示例6: test_failUnlessMatchesAssert
def test_failUnlessMatchesAssert(self):
"""
The C{failUnless*} test methods are a subset of the C{assert*} test
methods. This is intended to ensure that methods using the
I{failUnless} naming scheme are not added without corresponding methods
using the I{assert} naming scheme. The I{assert} naming scheme is
preferred, and new I{assert}-prefixed methods may be added without
corresponding I{failUnless}-prefixed methods.
"""
asserts = set(self._getAsserts())
failUnlesses = set(prefixedMethods(self, "failUnless"))
self.assertEqual(failUnlesses, asserts.intersection(failUnlesses))
示例7: getTasks
def getTasks(self):
"""
Get all tasks of this L{Service} object.
Intended to be used like::
globals().update(Service('name').getTasks())
at the module level of a fabfile.
@returns: L{dict} of L{fabric.tasks.Task}
"""
tasks = [(t, _stripPrefix(t))
for t in prefixedMethods(self, TASK_PREFIX)]
return {name: task(name=name)(t) for t, name in tasks}
示例8: __init__
def __init__(self, o=None):
self.xml = x = gtk.glade.XML(sibpath(__file__, "inspectro.glade"))
self.tree_view = x.get_widget("treeview")
colnames = ["Name", "Value"]
for i in range(len(colnames)):
self.tree_view.append_column(gtk.TreeViewColumn(colnames[i], gtk.CellRendererText(), text=i))
d = {}
for m in reflect.prefixedMethods(self, "on_"):
d[m.im_func.__name__] = m
self.xml.signal_autoconnect(d)
if o is not None:
self.inspect(o)
self.ns = {"inspect": self.inspect}
iwidget = x.get_widget("input")
self.input = ConsoleInput(iwidget)
self.input.toplevel = self
iwidget.connect("key_press_event", self.input._on_key_press_event)
self.output = ConsoleOutput(x.get_widget("output"))
示例9: getTasks
def getTasks(self, role=None):
"""
Get all tasks of this L{Service} object.
Intended to be used like::
globals().update(Service('name').getTasks())
at the module level of a fabfile.
@returns: L{dict} of L{fabric.tasks.Task}
"""
tasks = prefixedMethods(self, TASK_PREFIX)
tasks = ((_stripPrefix(t), t) for t in tasks)
tasks = ((name, task(name=name)(t)) for name, t in tasks)
if role:
tasks = ((name, roles(role)(t)) for name, t in tasks)
return dict(tasks)
示例10: test_failIf_matches_assertNot
def test_failIf_matches_assertNot(self):
asserts = prefixedMethods(unittest.SynchronousTestCase, 'assertNot')
failIfs = prefixedMethods(unittest.SynchronousTestCase, 'failIf')
self.assertEqual(sorted(asserts, key=self._name),
sorted(failIfs, key=self._name))
示例11: check
def check(self, dom, filename):
self.hadErrors = 0
for method in reflect.prefixedMethods(self, 'check_'):
method(dom, filename)
if self.hadErrors:
raise process.ProcessingFailure("invalid format")
示例12: test_failIf_matches_assertNot
def test_failIf_matches_assertNot(self):
asserts = reflect.prefixedMethods(unittest.TestCase, "assertNot")
failIfs = reflect.prefixedMethods(unittest.TestCase, "failIf")
self.assertEqual(sorted(asserts, key=self._name), sorted(failIfs, key=self._name))
示例13: test_failIf_matches_assertNot
def test_failIf_matches_assertNot(self):
asserts = reflect.prefixedMethods(unittest.TestCase, 'assertNot')
failIfs = reflect.prefixedMethods(unittest.TestCase, 'failIf')
self.failUnlessEqual(dsu(asserts, self._name),
dsu(failIfs, self._name))
示例14: test_failUnless_matches_assert
def test_failUnless_matches_assert(self):
asserts = self._getAsserts()
failUnlesses = reflect.prefixedMethods(self, 'failUnless')
self.failUnlessEqual(dsu(asserts, self._name),
dsu(failUnlesses, self._name))
示例15: test_51_h263_sharedvideosink
recv.videocodec = 'h264'
send.videocodec = recv.videocodec
self.run(recv, send)
def test_51_h263_sharedvideosink(self):
""" Test with sharedvideosink """
recv, send = self.argfactory('video')
recv.videosink = 'sharedvideosink'
recv.videocodec = 'h263'
send.videocodec = recv.videocodec
self.run(recv, send)
def test_52_theora_deinterlace_sharedvideosink(self):
""" Test with sharedvideosink """
recv, send = self.argfactory('video')
recv.videosink = 'sharedvideosink'
recv.videocodec = 'theora'
send.videocodec = recv.videocodec
recv.deinterlace = True
self.run(recv, send)
if __name__ == '__main__':
# here we run all the tests thanks to the wonders of reflective programming
TESTS = prefixedMethods(MilhouseTests(), 'test_01')
for test in TESTS:
print 'TEST: ' + test.__doc__
test()