Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-62432: unittest runner: Exit code 5 if no tests were run#102051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gpshead merged 13 commits intopython:mainfromstefanor:fail-zero-tests
Apr 27, 2023
Merged
Changes from1 commit
Commits
Show all changes
13 commits
Select commitHold shift + click to select a range
0a2007d
Refactor test_program to allow for multiple test suites
stefanorFeb 19, 2023
6532200
Refactor test_program to use assertRaises as a context manager
stefanorFeb 19, 2023
ebba337
unittest: Print an error message if no tests ran
stefanorFeb 19, 2023
5e1a88d
unittest runner: Exit code 5 if no tests were run
stefanorFeb 19, 2023
fb67714
Count the test run in our stub test so that the suite succeeds
stefanorFeb 19, 2023
0687ca8
Update ACKs
stefanorFeb 19, 2023
3ac2e71
Put success first in the if ladder
stefanorFeb 20, 2023
7470779
NO TESTS RAN, in past tense
stefanorFeb 20, 2023
ecb363c
The parameter name was testcase
stefanorFeb 20, 2023
7d6c322
Drop a comma
stefanorFeb 20, 2023
058e22c
Merge branch 'main' into fail-zero-tests
hauntsaninjaFeb 20, 2023
455ca8b
Merge branch 'main' into fail-zero-tests
AlexWaygoodApr 26, 2023
9fbab36
move 5 to a _NO_TESTS_EXITCODE constant.
gpsheadApr 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
NextNext commit
Refactor test_program to allow for multiple test suites
  • Loading branch information
@stefanor
stefanor committedFeb 19, 2023
commit0a2007dad63bd30ac66925f802feb9ee6418b40e
22 changes: 13 additions & 9 deletionsLib/test/test_unittest/test_program.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -71,15 +71,19 @@ def testExpectedFailure(self):
def testUnexpectedSuccess(self):
pass

class FooBarLoader(unittest.TestLoader):
"""Test loader that returns a suite containing FooBar."""
class TestLoader(unittest.TestLoader):
"""Test loader that returns a suite containing testsuite."""

def __init__(self, testcase):
self.testcase = testcase

def loadTestsFromModule(self, module):
return self.suiteClass(
[self.loadTestsFromTestCase(Test_TestProgram.FooBar)])
[self.loadTestsFromTestCase(self.testcase)])

def loadTestsFromNames(self, names, module):
return self.suiteClass(
[self.loadTestsFromTestCase(Test_TestProgram.FooBar)])
[self.loadTestsFromTestCase(self.testcase)])

def test_defaultTest_with_string(self):
class FakeRunner(object):
Expand All@@ -92,7 +96,7 @@ def run(self, test):
runner = FakeRunner()
program = unittest.TestProgram(testRunner=runner, exit=False,
defaultTest='test.test_unittest',
testLoader=self.FooBarLoader())
testLoader=self.TestLoader(self.FooBar))
sys.argv = old_argv
self.assertEqual(('test.test_unittest',), program.testNames)

Expand All@@ -108,7 +112,7 @@ def run(self, test):
program = unittest.TestProgram(
testRunner=runner, exit=False,
defaultTest=['test.test_unittest', 'test.test_unittest2'],
testLoader=self.FooBarLoader())
testLoader=self.TestLoader(self.FooBar))
sys.argv = old_argv
self.assertEqual(['test.test_unittest', 'test.test_unittest2'],
program.testNames)
Expand All@@ -118,7 +122,7 @@ def test_NonExit(self):
program = unittest.main(exit=False,
argv=["foobar"],
testRunner=unittest.TextTestRunner(stream=stream),
testLoader=self.FooBarLoader())
testLoader=self.TestLoader(self.FooBar))
self.assertTrue(hasattr(program, 'result'))
out = stream.getvalue()
self.assertIn('\nFAIL: testFail ', out)
Expand All@@ -136,7 +140,7 @@ def test_Exit(self):
argv=["foobar"],
testRunner=unittest.TextTestRunner(stream=stream),
exit=True,
testLoader=self.FooBarLoader())
testLoader=self.TestLoader(self.FooBar))
out = stream.getvalue()
self.assertIn('\nFAIL: testFail ', out)
self.assertIn('\nERROR: testError ', out)
Expand All@@ -152,7 +156,7 @@ def test_ExitAsDefault(self):
unittest.main,
argv=["foobar"],
testRunner=unittest.TextTestRunner(stream=stream),
testLoader=self.FooBarLoader())
testLoader=self.TestLoader(self.FooBar))
out = stream.getvalue()
self.assertIn('\nFAIL: testFail ', out)
self.assertIn('\nERROR: testError ', out)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp