[Python-checkins] r75095 - python/trunk/Lib/unittest/main.py

michael.foord python-checkins at python.org
Sun Sep 27 21:15:41 CEST 2009


Author: michael.foord
Date: Sun Sep 27 21:15:41 2009
New Revision: 75095
Log:
Test creation moved from TestProgram.parseArgs to TestProgram.createTests exclusively. Issue 6956.
Modified:
 python/trunk/Lib/unittest/main.py
Modified: python/trunk/Lib/unittest/main.py
==============================================================================
--- python/trunk/Lib/unittest/main.py	(original)
+++ python/trunk/Lib/unittest/main.py	Sun Sep 27 21:15:41 2009
@@ -109,9 +109,9 @@
 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 @@
 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


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /