Commit c6a65efb authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Fix unittest breakage on Python 2.4/2.5

Commit 70b0d2a2

 broke unittests on Python 2.4 and 2.5. Turns out that
Python 2.6 and above allow classes to be passed as custom test runners,
whereas earlier versions don't.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent d50a2223
......@@ -27,6 +27,7 @@ import stat
import tempfile
import unittest
import logging
import types
from ganeti import utils
......@@ -78,6 +79,18 @@ class GanetiTestProgram(unittest.TestProgram):
raise Exception("Assertion not evaluated")
# The following piece of code is a backport from Python 2.6. Python 2.4/2.5
# only accept class instances as test runners. Being able to pass classes
# reduces the amount of code necessary for using a custom test runner.
# 2.6 and above should use their own code, however.
if (self.testRunner and sys.hexversion < 0x2060000 and
isinstance(self.testRunner, (type, types.ClassType))):
self.testRunner = self.testRunner(verbosity=self.verbosity)
except TypeError:
# didn't accept the verbosity argument
self.testRunner = self.testRunner()
return unittest.TestProgram.runTests(self)
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