Revision: 3228
http://spambayes.svn.sourceforge.net/spambayes/?rev=3228&view=rev
Author: montanaro
Date: 2009-01-27 11:02:48 +0000 (Tue, 27 Jan 2009)
Log Message:
-----------
Get rid of bayes global. Restructuring code to avoid executing tons of code
at the module level awhile ago made that problematic.
Modified Paths:
--------------
trunk/spambayes/spambayes/test/test_smtpproxy.py
Modified: trunk/spambayes/spambayes/test/test_smtpproxy.py
===================================================================
--- trunk/spambayes/spambayes/test/test_smtpproxy.py 2009-01-27 02:59:19 UTC
(rev 3227)
+++ trunk/spambayes/spambayes/test/test_smtpproxy.py 2009-01-27 11:02:48 UTC
(rev 3228)
@@ -178,6 +178,10 @@
class SMTPProxyTest(unittest.TestCase):
"""Runs a self-test using TestSMTPServer, a minimal SMTP server
that receives mail and discards it."""
+ def __init__(self, *args):
+ unittest.TestCase.__init__(self, *args)
+ self.bayes = Classifier()
+
def setUp(self):
pass
@@ -247,12 +251,12 @@
s.quit()
def test_ham_intercept(self):
- pre_ham_trained = bayes.nham
+ pre_ham_trained = self.bayes.nham
s = smtplib.SMTP('localhost', 8026)
s.sendmail("[email protected]",
options["smtpproxy", "ham_address"], good1)
s.quit()
- post_ham_trained = bayes.nham
+ post_ham_trained = self.bayes.nham
self.assertEqual(pre_ham_trained+1, post_ham_trained)
def suite():
@@ -290,9 +294,7 @@
TestListener(socketMap=testSocketMap)
asyncore.loop(map=testSocketMap)
def runProxy():
- global bayes
- bayes = Classifier()
- trainer = SMTPTrainer(bayes, state)
+ trainer = SMTPTrainer(Classifier(), state)
BayesSMTPProxyListener('localhost', 8025, ('', 8026), trainer)
Dibbler.run()
thread.start_new_thread(runTestServer, ())
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Spambayes-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/spambayes-checkins