summaryrefslogtreecommitdiffstats
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2009-05-02 11:43:06 (GMT)
committerMichael Foord <fuzzyman@voidspace.org.uk>2009-05-02 11:43:06 (GMT)
commit829f6b80529bcf66bf52bb9b301bf718118b8316 (patch)
tree7850c9f8dda5c01911fb32083f97b05f529e36e5 /Lib/unittest.py
parent27f204dc297945378f72536e63936bf3bb995fdf (diff)
downloadcpython-829f6b80529bcf66bf52bb9b301bf718118b8316.zip
cpython-829f6b80529bcf66bf52bb9b301bf718118b8316.tar.gz
cpython-829f6b80529bcf66bf52bb9b301bf718118b8316.tar.bz2
Adds an exit parameter to unittest.main(). If False main no longer
calls sys.exit. Closes issue 3379. Michael Foord
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 71d94cf..43a2ced 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -1015,7 +1015,7 @@ class TestSuite(object):
def __eq__(self, other):
if not isinstance(other, self.__class__):
return NotImplemented
- return self._tests == other._tests
+ return list(self) == list(other)
def __ne__(self, other):
return not self == other
@@ -1469,7 +1469,7 @@ Examples:
"""
def __init__(self, module='__main__', defaultTest=None,
argv=None, testRunner=TextTestRunner,
- testLoader=defaultTestLoader):
+ testLoader=defaultTestLoader, exit=True):
if isinstance(module, basestring):
self.module = __import__(module)
for part in module.split('.')[1:]:
@@ -1478,6 +1478,8 @@ Examples:
self.module = module
if argv is None:
argv = sys.argv
+
+ self.exit = exit
self.verbosity = 1
self.defaultTest = defaultTest
self.testRunner = testRunner
@@ -1529,15 +1531,12 @@ Examples:
else:
# it is assumed to be a TestRunner instance
testRunner = self.testRunner
- result = testRunner.run(self.test)
- sys.exit(not result.wasSuccessful())
+ self.result = testRunner.run(self.test)
+ if self.exit:
+ sys.exit(not self.result.wasSuccessful())
main = TestProgram
-##############################################################################
-# Executing this module from the command line
-##############################################################################
-
if __name__ == "__main__":
main(module=None)