summaryrefslogtreecommitdiffstats
path: root/Lib/unittest
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2009-09-27 19:15:41 (GMT)
committerMichael Foord <fuzzyman@voidspace.org.uk>2009-09-27 19:15:41 (GMT)
commitd6aabcfe2f8eed7ad5bd440c95039ace610752a4 (patch)
treed2785e1d17a9f6fe4b9b4e18f7b6f6306ec37bfe /Lib/unittest
parent716a9ccd3db759aedf1796c929e7cb0ec822c79f (diff)
downloadcpython-d6aabcfe2f8eed7ad5bd440c95039ace610752a4.zip
cpython-d6aabcfe2f8eed7ad5bd440c95039ace610752a4.tar.gz
cpython-d6aabcfe2f8eed7ad5bd440c95039ace610752a4.tar.bz2
Test creation moved from TestProgram.parseArgs to TestProgram.createTests exclusively. Issue 6956.
Diffstat (limited to 'Lib/unittest')
-rw-r--r--Lib/unittest/main.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/Lib/unittest/main.py b/Lib/unittest/main.py
index a2eea86..bd758e0 100644
--- a/Lib/unittest/main.py
+++ b/Lib/unittest/main.py
@@ -109,9 +109,9 @@ class TestProgram(object):
if opt in ('-v','--verbose'):
self.verbosity = 2
if len(args) == 0 and self.defaultTest is None:
- self.test = self.testLoader.loadTestsFromModule(self.module)
- return
- if len(args) > 0:
+ # createTests will load tests from self.module
+ self.testNames = None
+ elif len(args) > 0:
self.testNames = args
if __name__ == '__main__':
# to support python -m unittest ...
@@ -123,8 +123,11 @@ class TestProgram(object):
self.usageExit(msg)
def createTests(self):
- self.test = self.testLoader.loadTestsFromNames(self.testNames,
- self.module)
+ if self.testNames is None:
+ self.test = self.testLoader.loadTestsFromModule(self.module)
+ else:
+ self.test = self.testLoader.loadTestsFromNames(self.testNames,
+ self.module)
def _do_discovery(self, argv, Loader=loader.TestLoader):
# handle command line args for test discovery