diff --git a/ChangeLog b/ChangeLog index 402adcb0a..bb194c3b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-07-13 Wolfgang Sourdeau + * Tests/Integration/sogotests.py: new module overriding + certain methods from the "unittest" module in order to + automatically execute the tests in verbose mode and by displaying + a timing of the test execution. + * Tests/Integration/test-webdavsync.py (WebdavSyncTest.test): adapted to suit the new handling of empty collections in SOGo diff --git a/Tests/Integration/all.py b/Tests/Integration/all.py index 7456b5cdf..a85826788 100755 --- a/Tests/Integration/all.py +++ b/Tests/Integration/all.py @@ -1,9 +1,15 @@ #!/usr/bin/python -import os, sys, unittest, getopt, traceback +import os, sys, unittest, getopt, traceback, time import preferences +import sogotests +import unittest if __name__ == "__main__": + unittest._TextTestResult.oldStartTest = unittest._TextTestResult.startTest + unittest._TextTestResult.startTest = sogotests.UnitTestTextTestResultNewStartTest + unittest._TextTestResult.stopTest = sogotests.UnitTestTextTestResultNewStopTest + loader = unittest.TestLoader() modules = [] # Duplicated from UIxPreferences.m @@ -28,7 +34,7 @@ if __name__ == "__main__": suite = loader.loadTestsFromNames(modules) print "%d tests in modules: '%s'" % (suite.countTestCases(), "', '".join(modules)) - runner = unittest.TextTestRunner() + runner = unittest.TextTestRunner(verbosity=2) if testLanguages: prefs = preferences.preferences() @@ -49,6 +55,7 @@ if __name__ == "__main__": print "Running test in %s (%d/%d)" % \ (languages[i], i + 1, len (languages)) + runner.verbosity = 2 runner.run(suite) # Revert to the original language prefs.set ("language", userLanguage) diff --git a/Tests/Integration/sogotests.py b/Tests/Integration/sogotests.py new file mode 100644 index 000000000..becf4f78c --- /dev/null +++ b/Tests/Integration/sogotests.py @@ -0,0 +1,23 @@ +import sys +import unittest +import time + +def UnitTestTextTestResultNewStartTest(self, test): + self.xstartTime = time.time() + self.oldStartTest(test) + +def UnitTestTextTestResultNewStopTest(self, test): + unittest.TestResult.stopTest(self, test) + endTime = time.time() + delta = endTime - self.xstartTime + print " %f ms" % delta + +def runTests(): + unittest._TextTestResult.oldStartTest = unittest._TextTestResult.startTest + unittest._TextTestResult.startTest = UnitTestTextTestResultNewStartTest + unittest._TextTestResult.stopTest = UnitTestTextTestResultNewStopTest + + argv = [] + argv.extend(sys.argv) + argv.append("-v") + unittest.main(argv=argv) diff --git a/Tests/Integration/test-caldav-scheduling.py b/Tests/Integration/test-caldav-scheduling.py index 1c3b189ef..bd9ffb7c6 100755 --- a/Tests/Integration/test-caldav-scheduling.py +++ b/Tests/Integration/test-caldav-scheduling.py @@ -6,14 +6,15 @@ from config import hostname, port, username, password, attendee1, attendee1_delegate import datetime +import sogotests import sys import time import unittest +import utilities import vobject import vobject.base import vobject.icalendar import webdavlib -import utilities import StringIO import xml.etree.ElementTree @@ -475,4 +476,4 @@ class CalDAVITIPDelegationTest(unittest.TestCase): "%stest-delegation.ics" % self.attendee1_calendar, 404) if __name__ == "__main__": - unittest.main() + sogotests.runTests() diff --git a/Tests/Integration/test-config.py b/Tests/Integration/test-config.py index 49b696de0..c76af88b2 100755 --- a/Tests/Integration/test-config.py +++ b/Tests/Integration/test-config.py @@ -2,7 +2,9 @@ from config import hostname, port, username, password, mailserver, subscriber_username, attendee1, attendee1_delegate +import sogotests import unittest +import time class CalDAVITIPDelegationTest(unittest.TestCase): def testConfigPY(self): @@ -51,4 +53,4 @@ class CalDAVITIPDelegationTest(unittest.TestCase): userHash[user] = True if __name__ == "__main__": - unittest.main() + sogotests.runTests() diff --git a/Tests/Integration/test-davacl.py b/Tests/Integration/test-davacl.py index 359ba9e2d..4202e59bb 100755 --- a/Tests/Integration/test-davacl.py +++ b/Tests/Integration/test-davacl.py @@ -7,6 +7,7 @@ import unittest import webdavlib import time +import sogotests import utilities # TODO: @@ -941,4 +942,4 @@ class DAVCalendarPublicAclTest(unittest.TestCase): "resource '%s' not returned" % resource) if __name__ == "__main__": - unittest.main() + sogotests.runTests() diff --git a/Tests/Integration/test-ical.py b/Tests/Integration/test-ical.py index 51831fb86..3d314f28c 100755 --- a/Tests/Integration/test-ical.py +++ b/Tests/Integration/test-ical.py @@ -3,6 +3,7 @@ from config import hostname, port, username, password, subscriber_username import unittest +import sogotests import utilities import webdavlib @@ -200,4 +201,4 @@ class iCalTest(unittest.TestCase): client.execute(delete) if __name__ == "__main__": - unittest.main() + sogotests.runTests() diff --git a/Tests/Integration/test-maildav.py b/Tests/Integration/test-maildav.py index c19137d6e..ee1e4d84a 100755 --- a/Tests/Integration/test-maildav.py +++ b/Tests/Integration/test-maildav.py @@ -3,6 +3,7 @@ from config import hostname, port, username, password, mailserver, subscriber_username, subscriber_password import sys +import sogotests import unittest import webdavlib import time @@ -673,4 +674,4 @@ class DAVMailCollectionTest(): self._deleteCollection ("test-dav-mail") if __name__ == "__main__": - unittest.main() + sogotests.runTests() diff --git a/Tests/Integration/test-webdav.py b/Tests/Integration/test-webdav.py index 375e3e9f4..f77e7ce1f 100755 --- a/Tests/Integration/test-webdav.py +++ b/Tests/Integration/test-webdav.py @@ -2,6 +2,7 @@ from config import hostname, port, username, password, subscriber_username +import sogotests import unittest import utilities import webdavlib @@ -151,4 +152,4 @@ class WebDAVTest(unittest.TestCase): propDisplayname)) if __name__ == "__main__": - unittest.main() + sogotests.runTests() diff --git a/Tests/Integration/test-webdavlib.py b/Tests/Integration/test-webdavlib.py index 20a4f6f10..781448d14 100755 --- a/Tests/Integration/test-webdavlib.py +++ b/Tests/Integration/test-webdavlib.py @@ -1,5 +1,6 @@ #!/usr/bin/python +import sogotests import unittest from webdavlib import * @@ -47,4 +48,4 @@ class HTTPUnparsedURLTest(unittest.TestCase): self.assertEquals(testURL.path, "/hooray") if __name__ == "__main__": - unittest.main() + sogotests.runTests() diff --git a/Tests/Integration/test-webdavsync.py b/Tests/Integration/test-webdavsync.py index be38865da..d26ec93fe 100755 --- a/Tests/Integration/test-webdavsync.py +++ b/Tests/Integration/test-webdavsync.py @@ -3,6 +3,7 @@ from config import hostname, port, username, password import sys +import sogotests import unittest import webdavlib import time @@ -19,6 +20,7 @@ class WebdavSyncTest(unittest.TestCase): self.client.execute(delete) def test(self): + """webdav sync""" # missing tests: # invalid tokens: negative, non-numeric, > current timestamp # non-empty collections: token validity, status codes for added, @@ -63,4 +65,4 @@ class WebdavSyncTest(unittest.TestCase): self.assertTrue(token > 0) if __name__ == "__main__": - unittest.main() + sogotests.runTests()