diff options
author | Petri Lehtinen <petri@digip.org> | 2013-02-23 17:52:51 (GMT) |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2013-02-23 17:55:49 (GMT) |
commit | 20054477f4671150e098b519dc1b85d7db6d27ab (patch) | |
tree | e2923f8ac088152e4919f2726273bc21c2d52b0a /Lib/unittest/test/test_program.py | |
parent | d784e53d9683b26822cc08b02a4bc6cb5a482e66 (diff) | |
download | cpython-20054477f4671150e098b519dc1b85d7db6d27ab.zip cpython-20054477f4671150e098b519dc1b85d7db6d27ab.tar.gz cpython-20054477f4671150e098b519dc1b85d7db6d27ab.tar.bz2 |
Issue #15132: Allow a list for the defaultTest argument of unittest.TestProgram
Patch by Jyrki Pulliainen
Diffstat (limited to 'Lib/unittest/test/test_program.py')
-rw-r--r-- | Lib/unittest/test/test_program.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/unittest/test/test_program.py b/Lib/unittest/test/test_program.py index 9794868..8e02f3c 100644 --- a/Lib/unittest/test/test_program.py +++ b/Lib/unittest/test/test_program.py @@ -64,6 +64,41 @@ class Test_TestProgram(unittest.TestCase): return self.suiteClass( [self.loadTestsFromTestCase(Test_TestProgram.FooBar)]) + def loadTestsFromNames(self, names, module): + return self.suiteClass( + [self.loadTestsFromTestCase(Test_TestProgram.FooBar)]) + + def test_defaultTest_with_string(self): + class FakeRunner(object): + def run(self, test): + self.test = test + return True + + old_argv = sys.argv + sys.argv = ['faketest'] + runner = FakeRunner() + program = unittest.TestProgram(testRunner=runner, exit=False, + defaultTest='unittest.test', + testLoader=self.FooBarLoader()) + sys.argv = old_argv + self.assertEquals(('unittest.test',), program.testNames) + + def test_defaultTest_with_iterable(self): + class FakeRunner(object): + def run(self, test): + self.test = test + return True + + old_argv = sys.argv + sys.argv = ['faketest'] + runner = FakeRunner() + program = unittest.TestProgram( + testRunner=runner, exit=False, + defaultTest=['unittest.test', 'unittest.test2'], + testLoader=self.FooBarLoader()) + sys.argv = old_argv + self.assertEquals(['unittest.test', 'unittest.test2'], + program.testNames) def test_NonExit(self): program = unittest.main(exit=False, |