[Buildbot-commits] buildbot/buildbot/test test_config.py,1.19,1.20 test_run.py,1.31,1.32 test_vc.py,1.29,1.30 test_web.py,1.17,1.18 test_status.py,1.18,1.19 test_control.py,1.5,1.6

Brian Warner warner at users.sourceforge.net
Tue May 17 10:14:13 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9810/buildbot/test

Modified Files:
	test_config.py test_run.py test_vc.py test_web.py 
	test_status.py test_control.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-187
Creator:  Brian Warner <warner at monolith.lothar.com>

fix deprecation warnings in test suite

	* everything: fixed all deprecation warnings when running against
	Twisted-2.0 . (at least all the ones in buildbot code, there are a
	few that come from Twisted itself). This involved putting most of
	the Twisted-version specific code in the new buildbot.twcompat
	module, and creating some abstract base classes in
	buildbot.changes.base and buildbot.status.base (which might be
	useful anyway). __implements__ is a nuisance and requires an ugly
	'if' clause everywhere.

	* buildbot/test/test_status.py (Mail.testMail): add a 0.1 second
	delay before finishing the test: it seems that smtp.sendmail
	doesn't hang up on the server, so we must wait a moment so it can
	hang up on us. This removes the trial warning about an unclean
	reactor.


Index: test_config.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_config.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- test_config.py	6 May 2005 04:57:59 -0000	1.19
+++ test_config.py	17 May 2005 10:14:10 -0000	1.20
@@ -14,6 +14,7 @@
 except ImportError:
     cvstoys = None
 
+from buildbot.twcompat import providedBy
 from buildbot.master import BuildMaster
 from twisted.application import service, internet
 from twisted.spread import pb
@@ -447,7 +448,7 @@
         # twisted.application.internet.TCPServer, then extract their .args
         # values to find the TCP ports they want to listen on
         for child in s:
-            if components.implements(child, service.IServiceCollection):
+            if providedBy(child, service.IServiceCollection):
                 for gc in self.servers(child, types):
                     yield gc
             if isinstance(child, types):

Index: test_control.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_control.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- test_control.py	26 Apr 2005 09:43:20 -0000	1.5
+++ test_control.py	17 May 2005 10:14:10 -0000	1.6
@@ -5,9 +5,9 @@
 from twisted.trial import unittest
 dr = unittest.deferredResult
 from twisted.internet import defer, reactor
-from twisted.python.components import implements
 
 from buildbot import master, interfaces
+from buildbot.twcompat import providedBy
 from buildbot.slave import bot
 from buildbot.status import builder
 from buildbot.status.builder import SUCCESS
@@ -108,11 +108,11 @@
         c = interfaces.IControl(m)
         builder_control = c.getBuilder("force")
         build_control = builder_control.forceBuild("bob", "I was bored")
-        self.failUnless(implements(build_control, interfaces.IBuildControl))
+        self.failUnless(providedBy(build_control, interfaces.IBuildControl))
         d = build_control.getStatus().waitUntilFinished()
         bs = dr(d)
 
-        self.failUnless(implements(bs, interfaces.IBuildStatus))
+        self.failUnless(providedBy(bs, interfaces.IBuildStatus))
         self.failUnless(bs.isFinished())
         self.failUnlessEqual(bs.getResults(), SUCCESS)
         #self.failUnlessEqual(bs.getResponsibleUsers(), ["bob"]) # TODO

Index: test_run.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_run.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- test_run.py	16 May 2005 08:42:10 -0000	1.31
+++ test_run.py	17 May 2005 10:14:10 -0000	1.32
@@ -10,8 +10,8 @@
 from buildbot import master, interfaces
 from buildbot.util import now
 from buildbot.slave import bot
-from buildbot.changes.changes import Change
-from buildbot.status import builder
+from buildbot.changes import changes
+from buildbot.status import base, builder
 
 def maybeWait(d, timeout="none"):
     # this is required for oldtrial (twisted-1.3.0) compatibility. When we
@@ -150,8 +150,7 @@
 class MyBuildSlave(bot.BuildSlave):
     botClass = MyBot
 
-class STarget:
-    __implements__ = interfaces.IStatusReceiver,
+class STarget(base.StatusReceiver):
     debug = False
 
     def __init__(self, mode):
@@ -226,7 +225,7 @@
         m.readConfig = True
         m.startService()
         cm = m.change_svc
-        c = Change("bob", ["Makefile", "foo/bar.c"], "changed stuff")
+        c = changes.Change("bob", ["Makefile", "foo/bar.c"], "changed stuff")
         cm.addChange(c)
         b1 = m.botmaster.builders["quick"]
         self.failUnless(b1.waiting)
@@ -590,6 +589,10 @@
                               fb, None, "forced build")
 
     def testIdle2(self):
+        # this used to be a testIdle2.skip="msg", but that caused a
+        # UserWarning when used with Twisted-1.3, which I think was an
+        # indication of an internal Trial problem
+        raise unittest.SkipTest("SF#1083403 pre-ping not yet implemented")
         m,s,c,s1 = self.disconnectSetup()
         # now suppose the slave goes missing
         self.disappearSlave()
@@ -603,7 +606,6 @@
         d = bs.waitUntilFinished()
         dr(d, 5)
         print bs.getText()
-    testIdle2.skip = "short timeout not yet implemented"
 
     def testSlaveTimeout(self):
         m,s,c,s1 = self.disconnectSetup2() # fast timeout

Index: test_status.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_status.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- test_status.py	16 May 2005 00:16:28 -0000	1.18
+++ test_status.py	17 May 2005 10:14:10 -0000	1.19
@@ -2,12 +2,12 @@
 
 import email, os
 
-from twisted.internet import defer
+from twisted.internet import defer, reactor
 from twisted.trial import unittest
 dr = unittest.deferredResult
-from twisted.python import components
 
 from buildbot import interfaces
+from buildbot.twcompat import implements, providedBy
 from buildbot.status import mail, builder
 from buildbot.status import progress, client # NEEDS COVERAGE
 
@@ -76,7 +76,11 @@
         return self.testlogs
 
 class MyLookup:
-    __implements__ = interfaces.IEmailLookup,
+    if implements:
+        implements(interfaces.IEmailLookup)
+    else:
+        __implements__ = interfaces.IEmailLookup,
+
     def getAddress(self, user):
         d = defer.Deferred()
         # With me now is Mr Thomas Walters of West Hartlepool who is totally
@@ -308,6 +312,15 @@
         print "sending mail to", dest
         d = mailer.buildFinished("builder1", b1, b1.results)
         dr(d)
+        # the mail has been sent, but the SMTP connection is still up
+        # (because smtp.sendmail relies upon the server to hang up). Spin for
+        # a moment to avoid the "unclean reactor" warning that Trial gives us
+        # if we finish before the socket is disconnected. Really, sendmail()
+        # ought to hang up the connection once it is finished: otherwise a
+        # malicious SMTP server could make us consume lots of memory.
+        d = defer.Deferred()
+        reactor.callLater(0.1, d.callback, None)
+        dr(d)
 
 class Progress(unittest.TestCase):
     def testWavg(self):
@@ -338,7 +351,7 @@
         res = b.getTestResults()
         self.failUnlessEqual(res.keys(), [testname])
         t = res[testname]
-        self.failUnless(components.implements(t, interfaces.ITestResult))
+        self.failUnless(providedBy(t, interfaces.ITestResult))
         self.failUnlessEqual(t.getName(), testname)
         self.failUnlessEqual(t.getResults(), builder.SUCCESS)
         self.failUnlessEqual(t.getText(), ["passed"])

Index: test_vc.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_vc.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- test_vc.py	17 May 2005 04:40:58 -0000	1.29
+++ test_vc.py	17 May 2005 10:14:10 -0000	1.30
@@ -224,7 +224,10 @@
             dr(defer.maybeDeferred(self.master.stopService))
         if self.httpServer:
             dr(self.httpServer.stopListening())
-            from twisted.protocols import http
+            try:
+                from twisted.web import http # Twisted-2.0
+            except ImportError:
+                from twisted.protocols import http # Twisted-1.3
             http._logDateTimeStop() # shut down the internal timer. DUMB!
 
     def doBuild(self, shouldSucceed=True):

Index: test_web.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_web.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- test_web.py	17 May 2005 03:36:54 -0000	1.17
+++ test_web.py	17 May 2005 10:14:10 -0000	1.18
@@ -12,6 +12,7 @@
 from twisted.web import client
 
 from buildbot import master, interfaces
+from buildbot.twcompat import providedBy
 from buildbot.status import html, builder
 from buildbot.changes.changes import Change
 from buildbot.process import step, base
@@ -79,7 +80,10 @@
 
     def tearDown(self):
         # grr.
-        from twisted.protocols import http
+        try:
+            from twisted.web import http # Twisted-2.0
+        except ImportError:
+            from twisted.protocols import http # Twisted-1.3
         http._logDateTimeStop()
         if self.master:
             d = self.master.stopService()
@@ -114,7 +118,7 @@
 
     def test_webPathname(self):
         # running a t.web.distrib server over a UNIX socket
-        if not components.implements(reactor, IReactorUNIX):
+        if not providedBy(reactor, IReactorUNIX):
             raise unittest.SkipTest("UNIX sockets not supported here")
         config = """
 from buildbot.status import html





More information about the Commits mailing list