本文整理汇总了Python中twisted.trial.util.acquireAttribute函数的典型用法代码示例。如果您正苦于以下问题:Python acquireAttribute函数的具体用法?Python acquireAttribute怎么用?Python acquireAttribute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了acquireAttribute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getTimeout
def getTimeout(self):
"""
Determine how long to run the test before considering it failed.
@return: A C{int} or C{float} giving a number of seconds.
"""
return acquireAttribute(self._parents, 'timeout', DEFAULT_TIMEOUT_DURATION)
示例2: test_foundOnLaterObject
def test_foundOnLaterObject(self):
"""
The same as L{test_foundOnEarlierObject}, but for the case where the 2nd
element in the object list has the attribute and the first does not.
"""
self.value = value = object()
self.assertTrue(value is acquireAttribute([object(), self], "value"))
示例3: setUp
def setUp(self):
# Scale time if configured
scale = util.acquireAttribute(self._parents, "timescale", None)
if scale is not None:
time.scale(scale)
else:
time.reset()
self.info("Test running with timescale: %r", time._get_scale())
示例4: getSlow
def getSlow(self):
"""
Return whether this test has been marked as slow. Checks on the
instance first, then the class, then the module, then packages. As
soon as it finds something with a C{slow} attribute, returns that.
Returns C{False} if it cannot find anything.
"""
return util.acquireAttribute(self._parents, 'slow', False)
示例5: test_notFoundDefault
def test_notFoundDefault(self):
"""
If none of the objects passed in the list to L{acquireAttribute} have
the requested attribute and a default value is given, the default value
is returned.
"""
default = object()
self.assertTrue(default is acquireAttribute([object()], "foo", default))
示例6: test_foundOnEarlierObject
def test_foundOnEarlierObject(self):
"""
The value returned by L{acquireAttribute} is the value of the requested
attribute on the first object in the list passed in which has that
attribute.
"""
self.value = value = object()
self.assertTrue(value is acquireAttribute([self, object()], "value"))
示例7: getSkip
def getSkip(self):
"""
Return the skip reason set on this test, if any is set. Checks on the
instance first, then the class, then the module, then packages. As
soon as it finds something with a C{skip} attribute, returns that.
Returns C{None} if it cannot find anything. See L{TestCase} docstring
for more details.
"""
return util.acquireAttribute(self._parents, 'skip', None)
示例8: _getSuppress
def _getSuppress(self):
"""
Returns any warning suppressions set for this test. Checks on the
instance first, then the class, then the module, then packages. As
soon as it finds something with a C{suppress} attribute, returns that.
Returns any empty list (i.e. suppress no warnings) if it cannot find
anything. See L{TestCase} docstring for more details.
"""
return util.acquireAttribute(self._parents, 'suppress', [])
示例9: setUp
def setUp(self):
log.test_reset()
self.assert_not_skipped()
# Scale time if configured
scale = util.acquireAttribute(self._parents, 'timescale', None)
if scale is not None:
time.scale(scale)
else:
time.reset()
self.info("Test running with timescale: %r", time._get_scale())
示例10: getTimeout
def getTimeout(self):
timeout = util.acquireAttribute(self._parents, "timeout", util.DEFAULT_TIMEOUT_DURATION)
try:
return float(timeout)
except (ValueError, TypeError):
# XXX -- this is here because sometimes people will have methods
# called 'timeout', or set timeout to 'orange', or something
# Particularly, test_news.NewsTestCase and ReactorCoreTestCase
# both do this.
warnings.warn("'timeout' attribute needs to be a number.", category=DeprecationWarning)
return util.DEFAULT_TIMEOUT_DURATION
示例11: getTodo
def getTodo(self):
"""
Return a L{Todo} object if the test is marked todo. Checks on the
instance first, then the class, then the module, then packages. As
soon as it finds something with a C{todo} attribute, returns that.
Returns C{None} if it cannot find anything. See L{TestCase} docstring
for more details.
"""
todo = util.acquireAttribute(self._parents, 'todo', None)
if todo is None:
return None
return makeTodo(todo)
示例12: __init__
def __init__(self, methodName=' impossible-name '):
log_keeper = log.get_default() or log.FluLogKeeper()
log.LogProxy.__init__(self, log_keeper)
log.Logger.__init__(self, self)
# Twisted changed the TestCase.__init__ signature several
# times.
#
# In versions older than 2.1.0 there was no __init__ method.
#
# In versions 2.1.0 up to 2.4.0 there is a __init__ method
# with a methodName kwarg that has a default value of None.
#
# In version 2.5.0 the default value of the kwarg was changed
# to "runTest".
#
# In versions above 2.5.0 God only knows what's the default
# value, as we do not currently support them.
import inspect
if not inspect.ismethod(unittest.TestCase.__init__):
# it's Twisted < 2.1.0
unittest.TestCase.__init__(self)
else:
# it's Twisted >= 2.1.0
if methodName == ' impossible-name ':
# we've been called with no parameters, use the
# default parameter value from the superclass
defaults = inspect.getargspec(unittest.TestCase.__init__)[3]
methodName = defaults[0]
unittest.TestCase.__init__(self, methodName=methodName)
self.log_name = self.id()
# Skip slow tests if '--skip-slow' option is enabled
if _getConfig().get('skip-slow'):
if self.getSlow() and not self.getSkip():
self.skip = 'slow test'
# Handle configurable attributes
for attr in self.configurable_attributes:
value = util.acquireAttribute(self._parents, attr, None)
if value is not None:
setattr(self, attr, value)
示例13: getTimeout
def getTimeout(self):
"""
Returns the timeout value set on this test. Checks on the instance
first, then the class, then the module, then packages. As soon as it
finds something with a C{timeout} attribute, returns that. Returns
L{util.DEFAULT_TIMEOUT_DURATION} if it cannot find anything. See
L{TestCase} docstring for more details.
"""
timeout = util.acquireAttribute(self._parents, 'timeout',
util.DEFAULT_TIMEOUT_DURATION)
try:
return float(timeout)
except (ValueError, TypeError):
# XXX -- this is here because sometimes people will have methods
# called 'timeout', or set timeout to 'orange', or something
# Particularly, test_news.NewsTestCase and ReactorCoreTestCase
# both do this.
warnings.warn("'timeout' attribute needs to be a number.",
category=DeprecationWarning)
return util.DEFAULT_TIMEOUT_DURATION
示例14: getSuppress
def getSuppress(self):
return util.acquireAttribute(self._parents, "suppress", [])
示例15: getTodo
def getTodo(self):
todo = util.acquireAttribute(self._parents, "todo", None)
if todo is None:
return None
return makeTodo(todo)