[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog/regressiontests - keywords.py:1.3 loadmail.py:1.7 regressionCatalog.py:1.3 regressionCatalogTiming.py:1.4 regressionUnicode.py:1.4 unittest_patched.py:1.3
Martijn Pieters
mj@zope.com
Wed, 14 Aug 2002 18:25:48 -0400
Update of /cvs-repository/Zope/lib/python/Products/ZCatalog/regressiontests
In directory cvs.zope.org:/tmp/cvs-serv27658/ZCatalog/regressiontests
Modified Files:
keywords.py loadmail.py regressionCatalog.py
regressionCatalogTiming.py regressionUnicode.py
unittest_patched.py
Log Message:
Clean up indentation and trailing whitespace.
=== Zope/lib/python/Products/ZCatalog/regressiontests/keywords.py 1.2 => 1.3 ===
--- Zope/lib/python/Products/ZCatalog/regressiontests/keywords.py:1.2 Tue Aug 7 11:04:45 2001
+++ Zope/lib/python/Products/ZCatalog/regressiontests/keywords.py Wed Aug 14 18:25:16 2002
@@ -8,41 +8,39 @@
def __init__(self):
self.kw = []
-
+
def build(self,mbox,limit):
-
+
mb = mailbox.UnixMailbox(open(mbox))
msg = mb.next()
-
+
while msg and len(self.kw) < limit:
sub = msg.dict.get("subject","").split(' ')
for f in sub:
ok = 1
- for c in f:
+ for c in f:
if not c in string.letters: ok=0
-
+
if ok==1 and not f in self.kw : self.kw.append(f)
-
+
msg = mb.next()
-
+
P = cPickle.Pickler(open('data/keywords','w'))
P.dump(self.kw)
-
+
def reload(self):
P = cPickle.Unpickler(open('data/keywords','r'))
self.kw = P.load()
-
-
+
+
def keywords(self):
return self.kw
-
-
+
+
if __name__=="__main__":
k = Keywords()
k.build("/home/andreas/zope.mbox",1000)
-
-
=== Zope/lib/python/Products/ZCatalog/regressiontests/loadmail.py 1.6 => 1.7 ===
--- Zope/lib/python/Products/ZCatalog/regressiontests/loadmail.py:1.6 Mon Aug 12 18:58:13 2002
+++ Zope/lib/python/Products/ZCatalog/regressiontests/loadmail.py Wed Aug 14 18:25:16 2002
@@ -89,13 +89,13 @@
3.41 (0, 1)
as described above.
-
+
pdebug command args
Run one of the other commands in the Python debugger.
sample suite of tests::
-
+
cd lib/python
python Products/ZCatalog/regressiontests/loadmail.py base ~/zope.mbox 1000
python Products/ZCatalog/regressiontests/loadmail.py index 100
@@ -162,7 +162,7 @@
dest.manage_addFolder(name)
else:
Products.BTreeFolder.BTreeFolder.manage_addBTreeFolder(dest, name)
-
+
dest=getattr(dest, name)
f=open(mbox)
mb=mailbox.UnixMailbox(f)
@@ -186,7 +186,7 @@
message=mb.next()
dest.number_of_messages=i
- print
+ print
get_transaction().commit()
def loadinc(name, mb, printstat=0, max=99999999, wait=1):
@@ -233,8 +233,8 @@
doc=app=mdest=0
jar.close()
-
-
+
+
if printstat: sys.stdout.write("\t%s\t%s\t\n" % (i, f.tell()))
sys.stdout.flush()
return rconflicts, wconflicts
@@ -259,7 +259,7 @@
r.PARENTS=[0, app.mail]
app.cat.manage_catalogFoundItems(r,r,'','',['DTML Document'])
get_transaction().commit()
-
+
def index():
os.environ['STUPID_LOG_FILE']=''
os.environ['STUPID_LOG_SEVERITY']='-111'
@@ -276,16 +276,16 @@
import PLexicon
from Products.ZCTextIndex.Lexicon \
import Splitter, CaseNormalizer
-
+
app.cat._setObject('lex',
PLexicon('lex', '', Splitter(), CaseNormalizer())
)
-
+
class extra:
doc_attr = 'PrincipiaSearchSource'
lexicon_id = 'lex'
index_type = 'Okapi BM25 Rank'
-
+
app.cat.addIndex('PrincipiaSearchSource', 'ZCTextIndex', extra)
get_transaction().commit()
@@ -377,7 +377,7 @@
print t, c, size, mem
#hist("%s-%s-%s" % (omin, count, threads))
-
+
Zope.DB.close()
words=['banishment', 'indirectly', 'imprecise', 'peeks',
@@ -608,7 +608,7 @@
doc=app=0
jar.close()
-
+
return rconflicts, wconflicts
def edit():
@@ -671,7 +671,7 @@
print t, c, size, mem
#hist("e%s" % (threads))
-
+
Zope.DB.close()
def VmSize():
=== Zope/lib/python/Products/ZCatalog/regressiontests/regressionCatalog.py 1.2 => 1.3 === (426/526 lines abridged)
--- Zope/lib/python/Products/ZCatalog/regressiontests/regressionCatalog.py:1.2 Tue Aug 7 11:04:45 2001
+++ Zope/lib/python/Products/ZCatalog/regressiontests/regressionCatalog.py Wed Aug 14 18:25:16 2002
@@ -59,28 +59,28 @@
""" some wrapper stuff around ZODB """
def __init__(self, file = "data/work/Data.fs",open=1):
-
+
self.db = ZODB.DB( ZODB.FileStorage.FileStorage(file) )
if open==1:
self.connection = self.db.open()
self.root = self.connection.root()
-
+
def write(self,name,obj):
self.root[name] = obj
get_transaction().commit()
-
+
def read(self,name):
return self.root[name]
-
+
def __del__(self):
self.db.close()
-
-
+
+
class testCatalog(Persistence.Persistent,unittest.TestCase):
""" Wrapper around the catalog stuff """
@@ -89,7 +89,7 @@
self.num_files = 0
self.keywords = []
self.maxfiles = maxfiles
-
+
self._vocabulary = Vocabulary.Vocabulary('Vocabulary',
'Vocabulary', globbing=1)
self._catalog = ZCatalog.ZCatalog("zcatalog")
@@ -118,7 +118,7 @@
try:
self.catMessage(msg)
self.msg_ids.append(msg.dict["message-id"])
[-=- -=- -=- 426 lines omitted -=- -=- -=-]
+
def main():
@@ -606,7 +606,7 @@
optsLst = map(lambda x: x[0],opts)
if optsLst==[]: usage(os.path.basename(sys.argv[0])); sys.exit(0)
-
+
for k,v in opts:
if k in ['-h','--help'] : usage(os.path.basename(sys.argv[0])); sys.exit(0)
if k == "-f": maxFiles = string.atoi(v)
@@ -616,7 +616,7 @@
if '-i' in optsLst:
unittest.TextTestRunner().run(get_tests('init'))
-
+
if '-b' in optsLst:
unittest.TextTestRunner().run(get_tests('bench1'))
@@ -680,8 +680,8 @@
testSearches("testReindexingAndModify",numThreads=1),
# testSearches("testUpdates",numThreads=10,numUpdates=100),
)
-
- init_tests = (
+
+ init_tests = (
BuildEnv("buildTestEnvironment",dataDir,maxFiles) ,
)
@@ -698,13 +698,12 @@
test_suite()
def debug():
- test_suite().debug()
-
+ test_suite().debug()
+
def pdebug():
import pdb
pdb.run('debug()')
if __name__ == '__main__':
- main()
-
+ main()
=== Zope/lib/python/Products/ZCatalog/regressiontests/regressionCatalogTiming.py 1.3 => 1.4 ===
--- Zope/lib/python/Products/ZCatalog/regressiontests/regressionCatalogTiming.py:1.3 Fri Oct 5 14:39:32 2001
+++ Zope/lib/python/Products/ZCatalog/regressiontests/regressionCatalogTiming.py Wed Aug 14 18:25:16 2002
@@ -51,7 +51,7 @@
c.manage_addIndex('from', 'TextIndex')
c.manage_addIndex('date', 'FieldIndex')
c.manage_addIndex('raw', 'TextIndex')
-
+
def tearDown(self):
try: self.app._delObject('catalogtest')
except AttributeError: pass
@@ -61,7 +61,7 @@
except AttributeError: pass
self.app = None
del self.app
-
+
def checkTimeBulkIndex(self):
print
c = self.app.catalogtest.catalog
@@ -109,7 +109,7 @@
assert len(c({'raw':'chris'})) != 0
assert len(c({'raw':'gghdjkasjdsda'})) == 0
assert c({'PrincipiaSearchSource':'the*'})
-
+
def checkTimeSubcommit(self):
print
for x in (None,100,500,1000,10000):
@@ -190,7 +190,7 @@
def test_suite():
s1 = makeSuite(TestTimeIndex, 'check')
-
+
testsuite = TestSuite((s1,))
return testsuite
@@ -199,7 +199,7 @@
if not os.path.isfile(mb):
print "do you want to get the zope.mbox file from lists.zope.org?"
print "it's required for testing (98MB, ~ 30mins on fast conn)"
- print "it's also available at korak:/home/chrism/zope.mbox"
+ print "it's also available at korak:/home/chrism/zope.mbox"
print "-- type 'Y' or 'N'"
a = raw_input()
if lower(a[:1]) == 'y':
@@ -235,8 +235,7 @@
test_suite().debug()
if __name__=='__main__':
- if len(sys.argv) > 1:
- globals()[sys.argv[1]]()
- else:
- main()
-
+ if len(sys.argv) > 1:
+ globals()[sys.argv[1]]()
+ else:
+ main()
=== Zope/lib/python/Products/ZCatalog/regressiontests/regressionUnicode.py 1.3 => 1.4 ===
--- Zope/lib/python/Products/ZCatalog/regressiontests/regressionUnicode.py:1.3 Thu Oct 18 12:40:35 2001
+++ Zope/lib/python/Products/ZCatalog/regressiontests/regressionUnicode.py Wed Aug 14 18:25:16 2002
@@ -37,15 +37,15 @@
t4 = TO('i am a brown ' + unicode('fox') + ' dancing with a future alien',[])
t5 = TO("""
Die USA und Großbritannien können nach der Zerstörung der
- afghanischen Luftabwehr nun rund um die Uhr Angriffe fliegen. Das gab
+ afghanischen Luftabwehr nun rund um die Uhr Angriffe fliegen. Das gab
Verteidigungsminister Donald Rumsfeld bekannt. Bei den dreitägigen Angriffen
seien auch bis auf einen alle Flugplätze der Taliban zerstört worden. Rumsfeld
- erklärte weiter, er könne die Berichte nicht bestätigen, wonach bei den
+ erklärte weiter, er könne die Berichte nicht bestätigen, wonach bei den
amerikanischen Angriffen vier afghanische Mitarbeiter einer von den UN
finanzierten Hilfsorganisation getötet wurden. Diese könnten auch durch
Gegenfeuer der Taliban getötet worden sein.
""",[unicode('dreitägigen','latin1'),'zerstört'])
-
+
self.cat.catalog_object(t1,"o1")
self.cat.catalog_object(t2,"o2")
@@ -59,7 +59,7 @@
('dreitägigen',('o5',))
]
-
+
self.kw_tests = [ ('quick',('o1',) ),
('zerstört',('o3','o5')),
('dreitägigen',('o5',))
=== Zope/lib/python/Products/ZCatalog/regressiontests/unittest_patched.py 1.2 => 1.3 ===
--- Zope/lib/python/Products/ZCatalog/regressiontests/unittest_patched.py:1.2 Tue Aug 7 11:04:45 2001
+++ Zope/lib/python/Products/ZCatalog/regressiontests/unittest_patched.py Wed Aug 14 18:25:16 2002
@@ -31,7 +31,7 @@
# This is patched version of unittest.py and allows to pass additional
# parameters to the TestCase constructor.
-# This special version is only need to run the regression test
+# This special version is only need to run the regression test
# in testCatalog.py#
#
# ajung
@@ -101,7 +101,7 @@
def stop(self):
"Indicates that the tests should be aborted"
self.shouldStop = 1
-
+
def __repr__(self):
return "<%s run=%i errors=%i failures=%i>" % \
(self.__class__, self.testsRun, len(self.errors),
@@ -111,14 +111,14 @@
class TestCase:
"""A class whose instances are single test cases.
- Test authors should subclass TestCase for their own tests. Construction
+ Test authors should subclass TestCase for their own tests. Construction
and deconstruction of the test's environment ('fixture') can be
implemented by overriding the 'setUp' and 'tearDown' methods respectively.
By default, the test code itself should be placed in a method named
'runTest'.
-
- If the fixture may be used for many test cases, create as
+
+ If the fixture may be used for many test cases, create as
many test methods as are needed. When instantiating such a TestCase
subclass, specify in the constructor arguments the name of the test method
that the instance is to execute.
@@ -131,7 +131,7 @@
method when executed. Raises a ValueError if the instance does
not have a method with the specified name.
"""
-
+
try:
self.__testMethodName = methodName
testMethod = getattr(self, methodName)
@@ -250,7 +250,7 @@
def fail(self, msg=None):
"""Fail immediately, with the given message."""
raise AssertionError, msg
-
+
def __exc_info(self):
"""Return a version of sys.exc_info() with the traceback frame
minimised; usually the top level of the traceback frame is not
@@ -465,7 +465,7 @@
if args: apply(self.write, args)
self.write(self.linesep)
-
+
class _JUnitTextTestResult(TestResult):
"""A test result class that can print formatted text results to a stream.
@@ -481,12 +481,12 @@
self.stream.flush()
if error[0] is KeyboardInterrupt:
self.shouldStop = 1
-
+
def addFailure(self, test, error):
TestResult.addFailure(self,test,error)
self.stream.write('F')
self.stream.flush()
-
+
def startTest(self, test):
TestResult.startTest(self,test)
self.stream.write('.')
@@ -505,7 +505,7 @@
self.stream.writeln("%i) %s" % (i, test))
self.stream.writeln(errString)
i = i + 1
-
+
def printErrors(self):
self.printNumberedErrors("error",self.errors)
@@ -523,7 +523,7 @@
self.stream.writeln("Run: %i ; Failures: %i ; Errors: %i" %
(self.testsRun, len(self.failures),
len(self.errors)))
-
+
def printResult(self):
self.printHeader()
self.printErrors()
@@ -532,7 +532,7 @@
class JUnitTextTestRunner:
"""A test runner class that displays results in textual form.
-
+
The display format approximates that of JUnit's 'textui' test runner.
This test runner may be removed in a future version of PyUnit.
"""
@@ -565,7 +565,7 @@
self.stream = stream
self.lastFailure = None
self.descriptions = descriptions
-
+
def startTest(self, test):
TestResult.startTest(self, test)
if self.descriptions:
@@ -608,7 +608,7 @@
class VerboseTextTestRunner:
"""A test runner class that displays results in textual form.
-
+
It prints out the names of tests as they are run, errors as they
occur, and a summary of the results at the end of the test run.
"""
@@ -640,7 +640,7 @@
else:
self.stream.writeln("OK")
return result
-
+
# Which flavour of TextTestRunner is the default?
TextTestRunner = VerboseTextTestRunner
@@ -717,7 +717,7 @@
if self.testRunner is None:
self.testRunner = TextTestRunner()
result = self.testRunner.run(self.test)
- sys.exit(not result.wasSuccessful())
+ sys.exit(not result.wasSuccessful())
main = TestProgram