Commit 2ae3d5c1 authored by Hanno Schlichting's avatar Hanno Schlichting

Remove the ifmain blocks from tests

parent a172bbeb
...@@ -15,6 +15,3 @@ def test_suite(): ...@@ -15,6 +15,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestNavigation), unittest.makeSuite(TestNavigation),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -17,6 +17,3 @@ def test_suite(): ...@@ -17,6 +17,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestPersistent), unittest.makeSuite(TestPersistent),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -15,6 +15,3 @@ def test_suite(): ...@@ -15,6 +15,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestUndoSupport), unittest.makeSuite(TestUndoSupport),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -38,6 +38,3 @@ def test_suite(): ...@@ -38,6 +38,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
DocTestSuite(), DocTestSuite(),
)) ))
if __name__ == '__main__':
unittest.main()
...@@ -105,101 +105,3 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification ...@@ -105,101 +105,3 @@ http://www.zope.org/Members/michel/Projects/Interfaces/ObserverAndNotification
self._observers.remove( bozo ) self._observers.remove( bozo )
except: except:
pass pass
#
# Unit tests
#
if __name__ == '__main__':
class DontGoHere( Exception ): pass
class Idawanna( Exception ): pass
class TestSubject( DefaultObservable ):
def __init__( self, paths ):
DefaultObservable.__init__( self, 0 )
self.paths = paths
def restrictedTraverse( self, path, default ):
return self.paths.get( path, default )
callbacks = {}
def recordCallback( name, subject, event ):
cbrec = callbacks.get( name, None )
if cbrec is None:
cbrec = callbacks[ name ] = []
cbrec.append( ( subject, event ) )
class TestObserver:
def __call__( self, subject, event ):
recordCallback( 'direct', subject, event )
def namedCallback( self, subject, event ):
recordCallback( 'named', subject, event )
def named2Callback( self, subject, event ):
recordCallback( 'named2', subject, event )
def boundCallback( self, subject, event ):
recordCallback( 'bound', subject, event )
def freefuncObserver( subject, event ):
recordCallback( 'freefunc', subject, event )
def tryVeto( subject, event ):
""" Simulate attempted veto. """
raise Idawanna
observer = TestObserver()
# Simulate Zope's path traversal mechanism.
paths = {}
paths[ 'direct' ] = observer
paths[ 'direct/named' ] = observer.namedCallback
paths[ 'direct/named2' ] = observer.named2Callback
paths[ 'bound' ] = observer.boundCallback
paths[ 'freefunc' ] = freefuncObserver
paths[ 'tryVeto' ] = tryVeto
subject = TestSubject( paths )
subject.registerObserver( 'direct' )
subject.registerObserver( 'bound' )
subject.registerObserver( 'direct/named' )
subject.registerObserver( ( 'direct', 'named2' ) )
subject.registerObserver( 'freefunc' )
subject.registerObserver( 'tryVeto' )
try:
subject.registerObserver( 'nonesuch' )
raise DontGoHere( 'path not found' )
except NameError:
pass
except:
import traceback
traceback.print_exc()
try:
subject.registerObserver( 3.1415926 )
raise DontGoHere( 'non-path' )
except TypeError:
pass
except:
import traceback
traceback.print_exc()
subject.notify( 'First event' )
subject.unregisterObserver( 'bound' )
subject.notify( { 'name' : 'Second event', 'value' : 42 } )
for key in callbacks.keys():
print '[%s]' % key
for cb in callbacks[ key ]:
print ' %s' % `cb`
...@@ -246,7 +246,3 @@ def test_suite(): ...@@ -246,7 +246,3 @@ def test_suite():
suite.addTest(unittest.makeSuite(TestGetAttr_c)) suite.addTest(unittest.makeSuite(TestGetAttr_c))
suite.addTest(unittest.makeSuite(TestGetAttrAnonymous_c)) suite.addTest(unittest.makeSuite(TestGetAttrAnonymous_c))
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -219,9 +219,3 @@ def test_suite(): ...@@ -219,9 +219,3 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( TestInitialization ) ) suite.addTest( unittest.makeSuite( TestInitialization ) )
return suite return suite
def main():
unittest.main(defaultTest='test_suite')
if __name__ == '__main__':
main()
...@@ -109,6 +109,3 @@ def test_suite(): ...@@ -109,6 +109,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(ApplicationTests), unittest.makeSuite(ApplicationTests),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
import unittest import unittest
import Testing
import cStringIO import cStringIO
...@@ -526,6 +525,3 @@ def test_suite(): ...@@ -526,6 +525,3 @@ def test_suite():
suite.addTest( unittest.makeSuite( TestCopySupport ) ) suite.addTest( unittest.makeSuite( TestCopySupport ) )
suite.addTest( unittest.makeSuite( TestCopySupportSecurity ) ) suite.addTest( unittest.makeSuite( TestCopySupportSecurity ) )
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -15,6 +15,3 @@ def test_suite(): ...@@ -15,6 +15,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestFTPInterface), unittest.makeSuite(TestFTPInterface),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -358,7 +358,3 @@ def test_suite(): ...@@ -358,7 +358,3 @@ def test_suite():
unittest.makeSuite(FileTests), unittest.makeSuite(FileTests),
unittest.makeSuite(ImageTests), unittest.makeSuite(ImageTests),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -15,6 +15,3 @@ def test_suite(): ...@@ -15,6 +15,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestFindSupport), unittest.makeSuite(TestFindSupport),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -17,6 +17,3 @@ def test_suite(): ...@@ -17,6 +17,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestFolder), unittest.makeSuite(TestFolder),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -461,6 +461,3 @@ def test_suite(): ...@@ -461,6 +461,3 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( ObjectManagerTests ) ) suite.addTest( unittest.makeSuite( ObjectManagerTests ) )
return suite return suite
if __name__ == "__main__":
unittest.main()
...@@ -170,6 +170,3 @@ def test_suite(): ...@@ -170,6 +170,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestOrderSupport), unittest.makeSuite(TestOrderSupport),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -19,6 +19,3 @@ def test_suite(): ...@@ -19,6 +19,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestOrderedFolder), unittest.makeSuite(TestOrderedFolder),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -160,6 +160,3 @@ def test_suite(): ...@@ -160,6 +160,3 @@ def test_suite():
unittest.makeSuite(TestPropertyManager), unittest.makeSuite(TestPropertyManager),
unittest.makeSuite(TestPropertySheet), unittest.makeSuite(TestPropertySheet),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -358,9 +358,3 @@ def test_suite(): ...@@ -358,9 +358,3 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( TestRequestRange ) ) suite.addTest( unittest.makeSuite( TestRequestRange ) )
return suite return suite
def main():
unittest.TextTestRunner().run(test_suite())
if __name__ == '__main__':
main()
...@@ -120,6 +120,3 @@ def test_suite(): ...@@ -120,6 +120,3 @@ def test_suite():
unittest.makeSuite(TestItem_w__name__), unittest.makeSuite(TestItem_w__name__),
unittest.makeSuite(TestSimpleItem), unittest.makeSuite(TestSimpleItem),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -422,11 +422,6 @@ class TestTraverse( unittest.TestCase ): ...@@ -422,11 +422,6 @@ class TestTraverse( unittest.TestCase ):
self.folder1.unrestrictedTraverse('+something') is 'plus') self.folder1.unrestrictedTraverse('+something') is 'plus')
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
class SimpleClass(object): class SimpleClass(object):
"""Class with no __bobo_traverse__.""" """Class with no __bobo_traverse__."""
...@@ -685,6 +680,3 @@ def test_suite(): ...@@ -685,6 +680,3 @@ def test_suite():
from Testing.ZopeTestCase import FunctionalDocTestSuite from Testing.ZopeTestCase import FunctionalDocTestSuite
suite.addTest( FunctionalDocTestSuite() ) suite.addTest( FunctionalDocTestSuite() )
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -42,6 +42,3 @@ def test_suite(): ...@@ -42,6 +42,3 @@ def test_suite():
unittest.makeSuite(DTMLDocumentTests), unittest.makeSuite(DTMLDocumentTests),
unittest.makeSuite(FactoryTests), unittest.makeSuite(FactoryTests),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -52,6 +52,3 @@ def test_suite(): ...@@ -52,6 +52,3 @@ def test_suite():
unittest.makeSuite(DTMLMethodTests), unittest.makeSuite(DTMLMethodTests),
unittest.makeSuite(FactoryTests), unittest.makeSuite(FactoryTests),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -151,6 +151,3 @@ def test_suite(): ...@@ -151,6 +151,3 @@ def test_suite():
def main(): def main():
unittest.main(defaultTest='test_suite') unittest.main(defaultTest='test_suite')
if __name__ == '__main__':
main()
...@@ -194,6 +194,3 @@ def test_suite(): ...@@ -194,6 +194,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(XMLExportImportTests), unittest.makeSuite(XMLExportImportTests),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -18,7 +18,6 @@ import unittest ...@@ -18,7 +18,6 @@ import unittest
from doctest import DocFileSuite from doctest import DocFileSuite
from Testing.ZopeTestCase import FunctionalDocFileSuite from Testing.ZopeTestCase import FunctionalDocFileSuite
__docformat__ = "reStructuredText"
def test_suite(): def test_suite():
return unittest.TestSuite([ return unittest.TestSuite([
...@@ -26,6 +25,3 @@ def test_suite(): ...@@ -26,6 +25,3 @@ def test_suite():
FunctionalDocFileSuite('makesite.txt', FunctionalDocFileSuite('makesite.txt',
package="Products.Five.component"), package="Products.Five.component"),
]) ])
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -79,6 +79,3 @@ def test_suite(): ...@@ -79,6 +79,3 @@ def test_suite():
FunctionalDocFileSuite('README.txt'), FunctionalDocFileSuite('README.txt'),
FunctionalDocFileSuite('directives.txt'), FunctionalDocFileSuite('directives.txt'),
]) ])
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
#!/usr/bin/env python
"""Run all tests."""
import unittest
def test_suite():
suite = unittest.TestSuite()
for mname in ('DTMLTests', 'HTMLTests', 'Expressions', 'TALES'):
m = __import__('test' + mname)
suite.addTest(m.test_suite())
return suite
if __name__ == "__main__":
unittest.main(defaultTest='test_suite')
...@@ -188,6 +188,3 @@ class DTMLTests(zope.component.testing.PlacelessSetup, unittest.TestCase): ...@@ -188,6 +188,3 @@ class DTMLTests(zope.component.testing.PlacelessSetup, unittest.TestCase):
def test_suite(): def test_suite():
return unittest.makeSuite(DTMLTests, 'check') return unittest.makeSuite(DTMLTests, 'check')
if __name__=='__main__':
main()
...@@ -54,7 +54,3 @@ class MiscTests(unittest.TestCase): ...@@ -54,7 +54,3 @@ class MiscTests(unittest.TestCase):
def test_suite(): def test_suite():
return unittest.makeSuite(MiscTests) return unittest.makeSuite(MiscTests)
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -502,7 +502,3 @@ def test_suite(): ...@@ -502,7 +502,3 @@ def test_suite():
suite.addTests(unittest.makeSuite(ZPTUnicodeEncodingConflictResolution)) suite.addTests(unittest.makeSuite(ZPTUnicodeEncodingConflictResolution))
suite.addTests(unittest.makeSuite(PreferredCharsetUnicodeResolverTests)) suite.addTests(unittest.makeSuite(PreferredCharsetUnicodeResolverTests))
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -215,6 +215,3 @@ def test_suite(): ...@@ -215,6 +215,3 @@ def test_suite():
unittest.makeSuite(LineEndingsTestCase), unittest.makeSuite(LineEndingsTestCase),
unittest.makeSuite(LazyLoadingTestCase), unittest.makeSuite(LazyLoadingTestCase),
)) ))
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
...@@ -10,39 +10,26 @@ ...@@ -10,39 +10,26 @@
# FOR A PARTICULAR PURPOSE # FOR A PARTICULAR PURPOSE
# #
############################################################################## ##############################################################################
import sys, os, time import time
if __name__ == "__main__":
sys.path.insert(0, '../../..')
#os.chdir('../../..')
from Testing import makerequest from Testing import makerequest
import ZODB # in order to get Persistence.Persistent working import ZODB # in order to get Persistence.Persistent working
import transaction import transaction
import Acquisition import Acquisition
from Acquisition import aq_base
from Products.Sessions.BrowserIdManager import BrowserIdManager, \ from Products.Sessions.BrowserIdManager import BrowserIdManager, \
getNewBrowserId getNewBrowserId
from Products.Sessions.SessionDataManager import \ from Products.Sessions.SessionDataManager import \
SessionDataManager, SessionDataManagerErr SessionDataManager
from Products.Transience.Transience import \ from Products.Transience.Transience import \
TransientObjectContainer, TransientObject TransientObjectContainer
from Products.TemporaryFolder.TemporaryFolder import MountedTemporaryFolder from Products.TemporaryFolder.TemporaryFolder import MountedTemporaryFolder
from Products.TemporaryFolder.LowConflictConnection import \ from ZODB.POSException import ConflictError, \
LowConflictConnection
from ZODB.Connection import Connection
from ZODB.POSException import InvalidObjectReference, ConflictError, \
ReadConflictError, BTreesConflictError ReadConflictError, BTreesConflictError
from DateTime import DateTime from unittest import TestCase, TestSuite, makeSuite
from unittest import TestCase, TestSuite, TextTestRunner, makeSuite import threading, random
import time, threading, random
from cPickle import UnpickleableError
from ZODB.DemoStorage import DemoStorage from ZODB.DemoStorage import DemoStorage
from tempstorage.TemporaryStorage import TemporaryStorage
from OFS.Application import Application from OFS.Application import Application
from OFS.Folder import Folder
import sys
import time
import traceback import traceback
sys.setcheckinterval(200)
from Products.Transience.tests import fauxtime from Products.Transience.tests import fauxtime
import Products.Transience.Transience import Products.Transience.Transience
...@@ -261,7 +248,3 @@ def test_suite(): ...@@ -261,7 +248,3 @@ def test_suite():
test_multithread = makeSuite(TestMultiThread, 'test') test_multithread = makeSuite(TestMultiThread, 'test')
suite = TestSuite((test_multithread,)) suite = TestSuite((test_multithread,))
return suite return suite
if __name__ == '__main__':
runner = TextTestRunner(verbosity=9, descriptions=9)
runner.run(test_suite())
...@@ -152,7 +152,3 @@ def test_suite(): ...@@ -152,7 +152,3 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SiteErrorLogTests)) suite.addTest(unittest.makeSuite(SiteErrorLogTests))
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -145,6 +145,3 @@ def test_suite(): ...@@ -145,6 +145,3 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestZReST)) suite.addTest(unittest.makeSuite(TestZReST))
return suite return suite
if __name__ == '__main__':
unittest.main(defaultSuite='test_suite')
...@@ -595,102 +595,3 @@ class xmlPickler(NoBlanks, xyap): ...@@ -595,102 +595,3 @@ class xmlPickler(NoBlanks, xyap):
'persistent': save_persis, 'persistent': save_persis,
'unicode': save_unicode, 'unicode': save_unicode,
} }
# The rest is used for testing only
class C:
def __cmp__(self, other):
return cmp(self.__dict__, other.__dict__)
def test():
import xmllib
import pickle
c = C()
c.foo = 1
c.bar = 2
x = [0, 1, 2, 3]
y = ('abc', 'abc', c, c)
x.append(y)
x.append(y)
t = ()
l = []
s = ''
L = long('999999999999')
x.append(t)
x.append(l)
x.append(s)
x.append(L)
x.append(55555)
x.append(13)
r = [x]
print x
f = pickle.dumps(x)
print f
r.append(f)
q = ToXMLloads(f)
q = str(q)
q = '<?xml version="1.0"?>\n' + q
print q
r.append(q)
F = xmlPickler()
F.binary = 1
p = xmllib.XMLParser()
p.start_handlers = F.start_handlers
p.end_handlers = F.end_handlers
p.handle_data = F.handle_data
p.unknown_starttag = F.unknown_starttag
p.unknown_endtag = F.unknown_endtag
p._stack = F._stack
p.push = F.push
p.append = F.append
data = q.split('\n')
for l in data:
p.feed(l)
p.close()
z = p._stack
z = z[0][0]
print z, '\n'
r.append(z)
l = pickle.loads(z)
print l, '\n'
r.append(l)
def test1():
import xml.parsers.expat
import pickle
c = C()
c.foo = 1
c.bar = 2
x = [0, 1, 2, 3]
y = ('abc', 'abc', c, c)
x.append(y)
x.append(y)
t = ()
l = []
s = ''
L = long('999999999999')
x.append(t)
x.append(l)
x.append(s)
x.append(L)
x.append(5)
x.append(13)
print x, '\n'
f = pickle.dumps(x)
print f, '\n'
q = ToXMLloads(f)
q = str(q)
q = '<?xml version="1.0"?>\n' + q
print q, '\n'
F = xmlPickler()
F.binary = 0
p = xml.parsers.expat.ParserCreate()
p.CharacterDataHandler = F.handle_data
p.StartElementHandler = F.unknown_starttag
p.EndElementHandler = F.unknown_endtag
r = p.Parse(q)
print r, '\n'
if __name__ == '__main__':
test()
...@@ -22,8 +22,6 @@ Oh well. ...@@ -22,8 +22,6 @@ Oh well.
import string import string
import xml.parsers.expat import xml.parsers.expat
from pickle import *
class xyap: class xyap:
start_handlers = {} start_handlers = {}
...@@ -117,57 +115,3 @@ class xmlrpc(NoBlanks, XYap): ...@@ -117,57 +115,3 @@ class xmlrpc(NoBlanks, XYap):
'array': lambda self, tag, data: data[2], 'array': lambda self, tag, data: data[2],
'data': lambda self, tag, data: data[2:], 'data': lambda self, tag, data: data[2:],
} }
def test():
data = """<?xml version="1.0"?>
<methodCall>
<methodName>examples.getStateName
</methodName>
<params>
<param>
<value><i4>41</i4></value>
</param>
<param><value>
<struct>
<member>
<name>lowerBound</name>
<value><i4>18</i4></value>
</member>
<member>
<name>upperBound</name>
<value><i4>139</i4></value>
</member>
</struct></value>
</param>
<param><value>
<array>
<data>
<value><i4>12</i4></value>
<value><string>Egypt</string></value>
<value><boolean>0</boolean></value>
<value><i4>-31</i4></value>
</data>
</array></value>
</param>
</params>
</methodCall>
"""
data = data.split('\n')
r = []
for C in XYap, xmlrpc:
p = C()
for l in data:
p.feed(l)
p.close()
r.append(p._stack)
return r
if __name__=='__main__':
print test()
...@@ -56,10 +56,6 @@ and turn them into tests: ...@@ -56,10 +56,6 @@ and turn them into tests:
``FunctionalDocFileSuite`` and instantiate it, passing the name of the ``FunctionalDocFileSuite`` and instantiate it, passing the name of the
text file containing the test. For example: text file containing the test. For example:
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
from unittest import TestSuite from unittest import TestSuite
from Testing.ZopeTestCase import FunctionalDocFileSuite from Testing.ZopeTestCase import FunctionalDocFileSuite
...@@ -68,9 +64,6 @@ and turn them into tests: ...@@ -68,9 +64,6 @@ and turn them into tests:
FunctionalDocFileSuite('FunctionalDocTest.txt'), FunctionalDocFileSuite('FunctionalDocTest.txt'),
)) ))
if __name__ == '__main__':
framework()
Examples Examples
-------- --------
......
...@@ -26,10 +26,6 @@ infrastructure to set up the necessary environment. ...@@ -26,10 +26,6 @@ infrastructure to set up the necessary environment.
passing the name of the text file containing the tests. passing the name of the text file containing the tests.
For example: For example:
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
from unittest import TestSuite from unittest import TestSuite
from Testing.ZopeTestCase import ZopeDocFileSuite from Testing.ZopeTestCase import ZopeDocFileSuite
...@@ -38,9 +34,6 @@ infrastructure to set up the necessary environment. ...@@ -38,9 +34,6 @@ infrastructure to set up the necessary environment.
ZopeDocFileSuite('ZopeDocTest.txt'), ZopeDocFileSuite('ZopeDocTest.txt'),
)) ))
if __name__ == '__main__':
framework()
Examples Examples
-------- --------
......
...@@ -2,14 +2,6 @@ ...@@ -2,14 +2,6 @@
import unittest import unittest
TestRunner = unittest.TextTestRunner TestRunner = unittest.TextTestRunner
def framework():
if __name__ != '__main__':
return
if len(sys.argv) > 1:
errs = globals()[sys.argv[1]]()
else:
errs = TestRunner().run(test_suite())
sys.exit(errs and 1 or 0)
def debug(): def debug():
test_suite().debug() test_suite().debug()
...@@ -41,8 +33,3 @@ class Dummy: ...@@ -41,8 +33,3 @@ class Dummy:
return 'Dummy(%s)' % `self.__dict__` return 'Dummy(%s)' % `self.__dict__`
__repr__ = __str__ __repr__ = __str__
def Testing_file(*args):
dir = os.path.split(Testing.__file__)[0]
return apply(os.path.join, (dir,) + args)
...@@ -62,6 +62,3 @@ def test_suite(): ...@@ -62,6 +62,3 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MakerequestTests)) suite.addTest(unittest.makeSuite(MakerequestTests))
return suite return suite
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())
...@@ -705,6 +705,3 @@ def test_suite(): ...@@ -705,6 +705,3 @@ def test_suite():
unittest.makeSuite(TestBaseRequest), unittest.makeSuite(TestBaseRequest),
unittest.makeSuite(TestBaseRequestZope3Views), unittest.makeSuite(TestBaseRequestZope3Views),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -136,9 +136,3 @@ def debug(): ...@@ -136,9 +136,3 @@ def debug():
def pdebug(): def pdebug():
import pdb import pdb
pdb.run('debug()') pdb.run('debug()')
if __name__=='__main__':
if len(sys.argv) > 1:
globals()[sys.argv[1]]()
else:
main()
...@@ -1068,6 +1068,3 @@ def test_suite(): ...@@ -1068,6 +1068,3 @@ def test_suite():
suite.addTest(unittest.makeSuite(RecordTests)) suite.addTest(unittest.makeSuite(RecordTests))
suite.addTest(unittest.makeSuite(HTTPRequestTests)) suite.addTest(unittest.makeSuite(HTTPRequestTests))
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -10,9 +10,3 @@ def test_suite(): ...@@ -10,9 +10,3 @@ def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
suite.addTest( unittest.makeSuite( TestFileStreamIterator ) ) suite.addTest( unittest.makeSuite( TestFileStreamIterator ) )
return suite return suite
def main():
unittest.main(defaultTest='test_suite')
if __name__ == '__main__':
main()
...@@ -137,6 +137,3 @@ class TestBaseRequestPT(TestCase): ...@@ -137,6 +137,3 @@ class TestBaseRequestPT(TestCase):
def test_suite(): def test_suite():
return TestSuite( ( makeSuite(TestBaseRequestPT), ) ) return TestSuite( ( makeSuite(TestBaseRequestPT), ) )
if __name__ == '__main__':
main(defaultTest='test_suite')
...@@ -110,9 +110,5 @@ class ConvertersTests(unittest.TestCase): ...@@ -110,9 +110,5 @@ class ConvertersTests(unittest.TestCase):
self.assertEqual(field2ulines(to_convert), to_convert.splitlines()) self.assertEqual(field2ulines(to_convert), to_convert.splitlines())
def test_suite(): def test_suite():
return unittest.TestSuite((unittest.makeSuite(ConvertersTests),)) return unittest.TestSuite((unittest.makeSuite(ConvertersTests),))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -45,6 +45,3 @@ def test_suite(): ...@@ -45,6 +45,3 @@ def test_suite():
'ExceptionRaiser2': ExceptionRaiser2, 'ExceptionRaiser2': ExceptionRaiser2,
'ExceptionRaiser3': ExceptionRaiser3,}), 'ExceptionRaiser3': ExceptionRaiser3,}),
]) ])
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -212,6 +212,3 @@ class XMLRPCResponseTests(unittest.TestCase): ...@@ -212,6 +212,3 @@ class XMLRPCResponseTests(unittest.TestCase):
def test_suite(): def test_suite():
return unittest.TestSuite((unittest.makeSuite(XMLRPCResponseTests),)) return unittest.TestSuite((unittest.makeSuite(XMLRPCResponseTests),))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
import unittest import unittest
import time import time
from StringIO import StringIO
from ZServer import ClockServer from ZServer import ClockServer
class DummyLogger: class DummyLogger:
def __init__(self): def __init__(self):
self.L = [] self.L = []
...@@ -14,6 +14,7 @@ class DummyLogger: ...@@ -14,6 +14,7 @@ class DummyLogger:
def read(self): def read(self):
return ' '.join(self.L) return ' '.join(self.L)
class LogHelperTests(unittest.TestCase): class LogHelperTests(unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
return ClockServer.LogHelper return ClockServer.LogHelper
...@@ -22,13 +23,13 @@ class LogHelperTests(unittest.TestCase): ...@@ -22,13 +23,13 @@ class LogHelperTests(unittest.TestCase):
return self._getTargetClass()(*arg, **kw) return self._getTargetClass()(*arg, **kw)
def test_helper(self): def test_helper(self):
from StringIO import StringIO
logger = DummyLogger() logger = DummyLogger()
helper = self._makeOne(logger) helper = self._makeOne(logger)
self.assertEqual(helper.logger, logger) self.assertEqual(helper.logger, logger)
logger.log('ip', 'msg', foo=1, bar=2) logger.log('ip', 'msg', foo=1, bar=2)
self.assertEqual(logger.read(), 'ip msg') self.assertEqual(logger.read(), 'ip msg')
class ClockServerTests(unittest.TestCase): class ClockServerTests(unittest.TestCase):
def _getTargetClass(self): def _getTargetClass(self):
return ClockServer.ClockServer return ClockServer.ClockServer
...@@ -151,6 +152,3 @@ def test_suite(): ...@@ -151,6 +152,3 @@ def test_suite():
suite = unittest.makeSuite(ClockServerTests) suite = unittest.makeSuite(ClockServerTests)
suite.addTest(unittest.makeSuite(LogHelperTests)) suite.addTest(unittest.makeSuite(LogHelperTests))
return suite return suite
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
...@@ -293,6 +293,3 @@ def test_suite(): ...@@ -293,6 +293,3 @@ def test_suite():
suite = unittest.makeSuite(ZServerConfigurationTestCase) suite = unittest.makeSuite(ZServerConfigurationTestCase)
suite.addTest(unittest.makeSuite(MonitorServerConfigurationTestCase)) suite.addTest(unittest.makeSuite(MonitorServerConfigurationTestCase))
return suite return suite
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
...@@ -308,6 +308,3 @@ def test_suite(): ...@@ -308,6 +308,3 @@ def test_suite():
unittest.makeSuite(ZServerHTTPResponseEventsTestCase) unittest.makeSuite(ZServerHTTPResponseEventsTestCase)
)) ))
return suite return suite
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
#!/usr/bin/env python
"""Run all tests."""
import unittest
import glob
import os
import sys
def test_suite():
suite = unittest.TestSuite()
for mname in glob.glob(os.path.join(sys.path[0], 'test*.py')):
mname = os.path.split(mname)[1][:-3]
m = __import__(mname)
suite.addTest(m.test_suite())
return suite
if __name__ == "__main__":
unittest.main(defaultTest='test_suite')
import os, sys from unittest import TestCase, makeSuite
from unittest import TestCase, makeSuite, main
import string
from ZTUtils import Batch from ZTUtils import Batch
class BatchTests(TestCase): class BatchTests(TestCase):
...@@ -50,6 +47,3 @@ class BatchTests(TestCase): ...@@ -50,6 +47,3 @@ class BatchTests(TestCase):
def test_suite(): def test_suite():
return makeSuite(BatchTests) return makeSuite(BatchTests)
if __name__=='__main__':
main()
...@@ -214,7 +214,7 @@ class TreeTests(unittest.TestCase): ...@@ -214,7 +214,7 @@ class TreeTests(unittest.TestCase):
def testDecodeDecompressedSizeLimit(self): def testDecodeDecompressedSizeLimit(self):
import zlib import zlib
from ZTUtils.Tree import b2a, a2b, encodeExpansion, decodeExpansion from ZTUtils.Tree import b2a
big = b2a(zlib.compress('x' * (1024*1100))) big = b2a(zlib.compress('x' * (1024*1100)))
self.assert_(len(big) < 8192) # Must be under the input size limit self.assert_(len(big) < 8192) # Must be under the input size limit
self.assertRaises(ValueError, Tree.decodeExpansion, ':' + big) self.assertRaises(ValueError, Tree.decodeExpansion, ':' + big)
...@@ -222,6 +222,3 @@ class TreeTests(unittest.TestCase): ...@@ -222,6 +222,3 @@ class TreeTests(unittest.TestCase):
def test_suite(): def test_suite():
return unittest.makeSuite(TreeTests) return unittest.makeSuite(TreeTests)
if __name__=='__main__':
unittest.main()
import os, sys from unittest import TestCase, makeSuite
from unittest import TestCase, makeSuite, main
import string
import urllib import urllib
from ZTUtils.Zope import make_query, complex_marshal from ZTUtils.Zope import make_query, complex_marshal
from ZTUtils.Zope import make_hidden_input from ZTUtils.Zope import make_hidden_input
...@@ -66,6 +63,3 @@ class QueryTests(TestCase): ...@@ -66,6 +63,3 @@ class QueryTests(TestCase):
def test_suite(): def test_suite():
return makeSuite(QueryTests) return makeSuite(QueryTests)
if __name__=='__main__':
main()
...@@ -411,6 +411,3 @@ def test_suite(): ...@@ -411,6 +411,3 @@ def test_suite():
suite.addTest(unittest.makeSuite(ExceptionMessageRenderTest)) suite.addTest(unittest.makeSuite(ExceptionMessageRenderTest))
suite.addTest(unittest.makeSuite(ExceptionViewsTest)) suite.addTest(unittest.makeSuite(ExceptionViewsTest))
return suite return suite
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -397,6 +397,3 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase): ...@@ -397,6 +397,3 @@ class ZopeStarterTestCase(test_logger.LoggingTestBase):
def test_suite(): def test_suite():
return unittest.makeSuite(ZopeStarterTestCase) return unittest.makeSuite(ZopeStarterTestCase)
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
...@@ -223,6 +223,3 @@ class StartupTestCase(unittest.TestCase): ...@@ -223,6 +223,3 @@ class StartupTestCase(unittest.TestCase):
def test_suite(): def test_suite():
return unittest.makeSuite(StartupTestCase) return unittest.makeSuite(StartupTestCase)
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
...@@ -125,6 +125,3 @@ class TestWarnFilter(unittest.TestCase): ...@@ -125,6 +125,3 @@ class TestWarnFilter(unittest.TestCase):
def test_suite(): def test_suite():
return unittest.makeSuite(TestWarnFilter) return unittest.makeSuite(TestWarnFilter)
if __name__ == "__main__":
unittest.main(defaultTest="test_suite")
...@@ -15,6 +15,3 @@ def test_suite(): ...@@ -15,6 +15,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestCollection), unittest.makeSuite(TestCollection),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -15,6 +15,3 @@ def test_suite(): ...@@ -15,6 +15,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestEtagSupport), unittest.makeSuite(TestEtagSupport),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -14,6 +14,3 @@ def test_suite(): ...@@ -14,6 +14,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestLockItem), unittest.makeSuite(TestLockItem),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -34,6 +34,3 @@ def test_suite(): ...@@ -34,6 +34,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestUtilFunctions), unittest.makeSuite(TestUtilFunctions),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -81,6 +81,3 @@ def test_suite(): ...@@ -81,6 +81,3 @@ def test_suite():
unittest.makeSuite(TestLockNullResource), unittest.makeSuite(TestLockNullResource),
unittest.makeSuite(TestNullResource), unittest.makeSuite(TestNullResource),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -90,6 +90,3 @@ def test_suite(): ...@@ -90,6 +90,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestPUTFactory), unittest.makeSuite(TestPUTFactory),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -282,6 +282,3 @@ def test_suite(): ...@@ -282,6 +282,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestResource), unittest.makeSuite(TestResource),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -84,7 +84,3 @@ def test_suite(): ...@@ -84,7 +84,3 @@ def test_suite():
unittest.makeSuite(TestUnlock), unittest.makeSuite(TestUnlock),
unittest.makeSuite(TestPropPatch), unittest.makeSuite(TestPropPatch),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
...@@ -31,6 +31,3 @@ def test_suite(): ...@@ -31,6 +31,3 @@ def test_suite():
return unittest.TestSuite(( return unittest.TestSuite((
unittest.makeSuite(TestNode), unittest.makeSuite(TestNode),
)) ))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment