コード例 #1
0
ファイル: test_util.py プロジェクト: 12019/OpenWrt_Luci_Lua
 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"))
コード例 #2
0
ファイル: reactormixins.py プロジェクト: jaimematsuda/BolsaVL
    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)
コード例 #3
0
ファイル: reactormixins.py プロジェクト: 0004c/VTK
    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)
コード例 #4
0
ファイル: test_util.py プロジェクト: kuna/controller_server
 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"))
コード例 #5
0
ファイル: common.py プロジェクト: kowalski/feat
 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())
コード例 #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)
コード例 #7
0
ファイル: test_util.py プロジェクト: kuna/controller_server
 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"))
コード例 #8
0
ファイル: test_util.py プロジェクト: 12019/OpenWrt_Luci_Lua
 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))
コード例 #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))
コード例 #10
0
ファイル: test_util.py プロジェクト: 12019/OpenWrt_Luci_Lua
 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"))
コード例 #11
0
ファイル: _synctest.py プロジェクト: PeterLUYP/2016YCProject
 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', [])
コード例 #12
0
ファイル: _synctest.py プロジェクト: PeterLUYP/2016YCProject
 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)
コード例 #13
0
ファイル: _synctest.py プロジェクト: Architektor/PySnip
 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', [])
コード例 #14
0
ファイル: _synctest.py プロジェクト: Architektor/PySnip
 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)
コード例 #15
0
ファイル: common.py プロジェクト: 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())
コード例 #16
0
ファイル: unittest.py プロジェクト: galaxysd/BitTorrent
 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
コード例 #17
0
ファイル: _synctest.py プロジェクト: Architektor/PySnip
 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)
コード例 #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
コード例 #19
0
ファイル: common.py プロジェクト: 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)
コード例 #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)
コード例 #21
0
ファイル: _asynctest.py プロジェクト: 18636800170/videoWebsie
 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
コード例 #22
0
ファイル: _asynctest.py プロジェクト: AlexanderHerlan/syncpy
 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
コード例 #23
0
ファイル: unittest.py プロジェクト: galaxysd/BitTorrent
 def getSkip(self):
     return util.acquireAttribute(self._parents, "skip", None)
コード例 #24
0
 def getSuppress(self):
     return util.acquireAttribute(self._parents, 'suppress', [])
コード例 #25
0
 def getTodo(self):
     todo = util.acquireAttribute(self._parents, 'todo', None)
     if todo is None:
         return None
     return makeTodo(todo)
コード例 #26
0
ファイル: unittest.py プロジェクト: galaxysd/BitTorrent
 def getSuppress(self):
     return util.acquireAttribute(self._parents, "suppress", [])
コード例 #27
0
 def getSkip(self):
     return util.acquireAttribute(self._parents, 'skip', None)
コード例 #28
0
ファイル: unittest.py プロジェクト: galaxysd/BitTorrent
 def getTodo(self):
     todo = util.acquireAttribute(self._parents, "todo", None)
     if todo is None:
         return None
     return makeTodo(todo)