-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
gh-127221: Add colour to unittest output #127223
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
8cd1932
2744218
d01272f
06f1318
5a1de7c
d2b0e29
7226b77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
import pickle | ||
import subprocess | ||
from test import support | ||
from test.support import force_not_colorized | ||
|
||
import unittest | ||
from unittest.case import _Outcome | ||
|
@@ -106,6 +107,7 @@ def cleanup2(*args, **kwargs): | |
self.assertTrue(test.doCleanups()) | ||
self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))]) | ||
|
||
@force_not_colorized | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have to apply this decorator to so many methods that I almost wonder if it's worth having a custom metaclass that automatically adds it to each method on the class... or we could not use the Neither feels ideal; it might be that what you have now is in fact best! |
||
def testCleanUpWithErrors(self): | ||
class TestableTest(unittest.TestCase): | ||
def testNothing(self): | ||
|
@@ -416,6 +418,7 @@ def cleanup2(): | |
self.assertIsInstance(e2[1], CustomError) | ||
self.assertEqual(str(e2[1]), 'cleanup1') | ||
|
||
@force_not_colorized | ||
def test_with_errors_addCleanUp(self): | ||
ordering = [] | ||
class TestableTest(unittest.TestCase): | ||
|
@@ -439,6 +442,7 @@ def tearDownClass(cls): | |
['setUpClass', 'setUp', 'cleanup_exc', | ||
'tearDownClass', 'cleanup_good']) | ||
|
||
@force_not_colorized | ||
def test_run_with_errors_addClassCleanUp(self): | ||
ordering = [] | ||
class TestableTest(unittest.TestCase): | ||
|
@@ -462,6 +466,7 @@ def tearDownClass(cls): | |
['setUpClass', 'setUp', 'test', 'cleanup_good', | ||
'tearDownClass', 'cleanup_exc']) | ||
|
||
@force_not_colorized | ||
def test_with_errors_in_addClassCleanup_and_setUps(self): | ||
ordering = [] | ||
class_blow_up = False | ||
|
@@ -514,6 +519,7 @@ def tearDownClass(cls): | |
['setUpClass', 'setUp', 'tearDownClass', | ||
'cleanup_exc']) | ||
|
||
@force_not_colorized | ||
def test_with_errors_in_tearDownClass(self): | ||
ordering = [] | ||
class TestableTest(unittest.TestCase): | ||
|
@@ -590,6 +596,7 @@ def test(self): | |
'inner setup', 'inner test', 'inner cleanup', | ||
'end outer test', 'outer cleanup']) | ||
|
||
@force_not_colorized | ||
def test_run_empty_suite_error_message(self): | ||
class EmptyTest(unittest.TestCase): | ||
pass | ||
|
@@ -663,6 +670,7 @@ class Module(object): | |
self.assertEqual(cleanups, | ||
[((1, 2), {'function': 'hello'})]) | ||
|
||
@force_not_colorized | ||
def test_run_module_cleanUp(self): | ||
blowUp = True | ||
ordering = [] | ||
|
@@ -802,6 +810,7 @@ def tearDownClass(cls): | |
'tearDownClass', 'cleanup_good']) | ||
self.assertEqual(unittest.case._module_cleanups, []) | ||
|
||
@force_not_colorized | ||
def test_run_module_cleanUp_when_teardown_exception(self): | ||
ordering = [] | ||
class Module(object): | ||
|
@@ -963,6 +972,7 @@ def testNothing(self): | |
self.assertEqual(cleanups, | ||
[((1, 2), {'function': 3, 'self': 4})]) | ||
|
||
@force_not_colorized | ||
def test_with_errors_in_addClassCleanup(self): | ||
ordering = [] | ||
|
||
|
@@ -996,6 +1006,7 @@ def tearDownClass(cls): | |
['setUpModule', 'setUpClass', 'test', 'tearDownClass', | ||
'cleanup_exc', 'tearDownModule', 'cleanup_good']) | ||
|
||
@force_not_colorized | ||
def test_with_errors_in_addCleanup(self): | ||
ordering = [] | ||
class Module(object): | ||
|
@@ -1026,6 +1037,7 @@ def tearDown(self): | |
['setUpModule', 'setUp', 'test', 'tearDown', | ||
'cleanup_exc', 'tearDownModule', 'cleanup_good']) | ||
|
||
@force_not_colorized | ||
def test_with_errors_in_addModuleCleanup_and_setUps(self): | ||
ordering = [] | ||
module_blow_up = False | ||
|
@@ -1318,6 +1330,7 @@ def MockResultClass(*args): | |
expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY) | ||
self.assertEqual(runner._makeResult(), expectedresult) | ||
|
||
@force_not_colorized | ||
@support.requires_subprocess() | ||
def test_warnings(self): | ||
""" | ||
|
Uh oh!
There was an error while loading. Please reload this page.