Ejemplo n.º 1
0
 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"))
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
 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"))
Ejemplo n.º 5
0
 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())
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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"))
Ejemplo n.º 8
0
 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))
Ejemplo n.º 9
0
 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))
Ejemplo n.º 10
0
 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"))
Ejemplo n.º 11
0
 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', [])
Ejemplo n.º 12
0
 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 L{None} if it cannot find anything. See L{TestCase} docstring
     for more details.
     """
     return util.acquireAttribute(self._parents, 'skip', None)
Ejemplo n.º 13
0
 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', [])
Ejemplo n.º 14
0
 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)
Ejemplo n.º 15
0
Archivo: common.py Proyecto: f3at/feat
 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())
Ejemplo n.º 16
0
 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
Ejemplo n.º 17
0
 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)
Ejemplo n.º 18
0
 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
Ejemplo n.º 19
0
Archivo: common.py Proyecto: f3at/feat
    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)
Ejemplo n.º 20
0
 def getSkip(self) -> Tuple[bool, Optional[str]]:
     """
     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 in
     a tuple (L{True}, L{str}).
     If the C{skip} attribute does not exist, look for C{__unittest_skip__}
     and C{__unittest_skip_why__} attributes which are set by the standard
     library L{unittest.skip} function.
     Returns (L{False}, L{None}) if it cannot find anything.
     See L{TestCase} docstring for more details.
     """
     skipReason = util.acquireAttribute(self._parents, 'skip', None)
     doSkip = skipReason is not None
     if skipReason is None:
         doSkip = getattr(self, "__unittest_skip__", False)
         if doSkip:
             skipReason = getattr(self, "__unittest_skip_why__", "")
     return (doSkip, skipReason)
Ejemplo n.º 21
0
 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
Ejemplo n.º 22
0
 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
Ejemplo n.º 23
0
 def getSkip(self):
     return util.acquireAttribute(self._parents, "skip", None)
Ejemplo n.º 24
0
 def getSuppress(self):
     return util.acquireAttribute(self._parents, 'suppress', [])
Ejemplo n.º 25
0
 def getTodo(self):
     todo = util.acquireAttribute(self._parents, 'todo', None)
     if todo is None:
         return None
     return makeTodo(todo)
Ejemplo n.º 26
0
 def getSuppress(self):
     return util.acquireAttribute(self._parents, "suppress", [])
Ejemplo n.º 27
0
 def getSkip(self):
     return util.acquireAttribute(self._parents, 'skip', None)
Ejemplo n.º 28
0
 def getTodo(self):
     todo = util.acquireAttribute(self._parents, "todo", None)
     if todo is None:
         return None
     return makeTodo(todo)