mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-127873: Only check sys.flags.ignore_environment
for PYTHON*
env vars (#127877)
This commit is contained in:
parent
13475e0a5a
commit
05d12eecbd
22 changed files with 94 additions and 65 deletions
|
@ -4,10 +4,10 @@ import subprocess
|
|||
from test import support
|
||||
import unittest
|
||||
import test.test_unittest
|
||||
from test.support import force_not_colorized
|
||||
from test.test_unittest.test_result import BufferedWriter
|
||||
|
||||
|
||||
@support.force_not_colorized_test_class
|
||||
class Test_TestProgram(unittest.TestCase):
|
||||
|
||||
def test_discovery_from_dotted_path(self):
|
||||
|
@ -121,7 +121,6 @@ class Test_TestProgram(unittest.TestCase):
|
|||
self.assertEqual(['test.test_unittest', 'test.test_unittest2'],
|
||||
program.testNames)
|
||||
|
||||
@force_not_colorized
|
||||
def test_NonExit(self):
|
||||
stream = BufferedWriter()
|
||||
program = unittest.main(exit=False,
|
||||
|
@ -137,7 +136,6 @@ class Test_TestProgram(unittest.TestCase):
|
|||
'expected failures=1, unexpected successes=1)\n')
|
||||
self.assertEndsWith(out, expected)
|
||||
|
||||
@force_not_colorized
|
||||
def test_Exit(self):
|
||||
stream = BufferedWriter()
|
||||
with self.assertRaises(SystemExit) as cm:
|
||||
|
@ -155,7 +153,6 @@ class Test_TestProgram(unittest.TestCase):
|
|||
'expected failures=1, unexpected successes=1)\n')
|
||||
self.assertEndsWith(out, expected)
|
||||
|
||||
@force_not_colorized
|
||||
def test_ExitAsDefault(self):
|
||||
stream = BufferedWriter()
|
||||
with self.assertRaises(SystemExit):
|
||||
|
@ -171,7 +168,6 @@ class Test_TestProgram(unittest.TestCase):
|
|||
'expected failures=1, unexpected successes=1)\n')
|
||||
self.assertEndsWith(out, expected)
|
||||
|
||||
@force_not_colorized
|
||||
def test_ExitSkippedSuite(self):
|
||||
stream = BufferedWriter()
|
||||
with self.assertRaises(SystemExit) as cm:
|
||||
|
@ -184,7 +180,6 @@ class Test_TestProgram(unittest.TestCase):
|
|||
expected = '\n\nOK (skipped=1)\n'
|
||||
self.assertEndsWith(out, expected)
|
||||
|
||||
@force_not_colorized
|
||||
def test_ExitEmptySuite(self):
|
||||
stream = BufferedWriter()
|
||||
with self.assertRaises(SystemExit) as cm:
|
||||
|
|
|
@ -5,11 +5,7 @@ import traceback
|
|||
import unittest
|
||||
from unittest.util import strclass
|
||||
from test.support import warnings_helper
|
||||
from test.support import (
|
||||
captured_stdout,
|
||||
force_not_colorized,
|
||||
force_not_colorized_test_class,
|
||||
)
|
||||
from test.support import captured_stdout, force_not_colorized_test_class
|
||||
from test.test_unittest.support import BufferedWriter
|
||||
|
||||
|
||||
|
@ -37,6 +33,7 @@ def bad_cleanup2():
|
|||
raise ValueError('bad cleanup2')
|
||||
|
||||
|
||||
@force_not_colorized_test_class
|
||||
class Test_TestResult(unittest.TestCase):
|
||||
# Note: there are not separate tests for TestResult.wasSuccessful(),
|
||||
# TestResult.errors, TestResult.failures, TestResult.testsRun or
|
||||
|
@ -208,7 +205,6 @@ class Test_TestResult(unittest.TestCase):
|
|||
self.assertIs(test_case, test)
|
||||
self.assertIsInstance(formatted_exc, str)
|
||||
|
||||
@force_not_colorized
|
||||
def test_addFailure_filter_traceback_frames(self):
|
||||
class Foo(unittest.TestCase):
|
||||
def test_1(self):
|
||||
|
@ -235,7 +231,6 @@ class Test_TestResult(unittest.TestCase):
|
|||
self.assertEqual(len(dropped), 1)
|
||||
self.assertIn("raise self.failureException(msg)", dropped[0])
|
||||
|
||||
@force_not_colorized
|
||||
def test_addFailure_filter_traceback_frames_context(self):
|
||||
class Foo(unittest.TestCase):
|
||||
def test_1(self):
|
||||
|
@ -265,7 +260,6 @@ class Test_TestResult(unittest.TestCase):
|
|||
self.assertEqual(len(dropped), 1)
|
||||
self.assertIn("raise self.failureException(msg)", dropped[0])
|
||||
|
||||
@force_not_colorized
|
||||
def test_addFailure_filter_traceback_frames_chained_exception_self_loop(self):
|
||||
class Foo(unittest.TestCase):
|
||||
def test_1(self):
|
||||
|
@ -291,7 +285,6 @@ class Test_TestResult(unittest.TestCase):
|
|||
formatted_exc = result.failures[0][1]
|
||||
self.assertEqual(formatted_exc.count("Exception: Loop\n"), 1)
|
||||
|
||||
@force_not_colorized
|
||||
def test_addFailure_filter_traceback_frames_chained_exception_cycle(self):
|
||||
class Foo(unittest.TestCase):
|
||||
def test_1(self):
|
||||
|
@ -453,7 +446,6 @@ class Test_TestResult(unittest.TestCase):
|
|||
result.addUnexpectedSuccess(None)
|
||||
self.assertTrue(result.shouldStop)
|
||||
|
||||
@force_not_colorized
|
||||
def testFailFastSetByRunner(self):
|
||||
stream = BufferedWriter()
|
||||
runner = unittest.TextTestRunner(stream=stream, failfast=True)
|
||||
|
@ -465,6 +457,7 @@ class Test_TestResult(unittest.TestCase):
|
|||
self.assertEndsWith(stream.getvalue(), '\n\nOK\n')
|
||||
|
||||
|
||||
@force_not_colorized_test_class
|
||||
class Test_TextTestResult(unittest.TestCase):
|
||||
maxDiff = None
|
||||
|
||||
|
@ -627,7 +620,6 @@ class Test_TextTestResult(unittest.TestCase):
|
|||
test.run(result)
|
||||
return stream.getvalue()
|
||||
|
||||
@force_not_colorized
|
||||
def testDotsOutput(self):
|
||||
self.assertEqual(self._run_test('testSuccess', 1), '.')
|
||||
self.assertEqual(self._run_test('testSkip', 1), 's')
|
||||
|
@ -636,7 +628,6 @@ class Test_TextTestResult(unittest.TestCase):
|
|||
self.assertEqual(self._run_test('testExpectedFailure', 1), 'x')
|
||||
self.assertEqual(self._run_test('testUnexpectedSuccess', 1), 'u')
|
||||
|
||||
@force_not_colorized
|
||||
def testLongOutput(self):
|
||||
classname = f'{__name__}.{self.Test.__qualname__}'
|
||||
self.assertEqual(self._run_test('testSuccess', 2),
|
||||
|
@ -652,21 +643,17 @@ class Test_TextTestResult(unittest.TestCase):
|
|||
self.assertEqual(self._run_test('testUnexpectedSuccess', 2),
|
||||
f'testUnexpectedSuccess ({classname}.testUnexpectedSuccess) ... unexpected success\n')
|
||||
|
||||
@force_not_colorized
|
||||
def testDotsOutputSubTestSuccess(self):
|
||||
self.assertEqual(self._run_test('testSubTestSuccess', 1), '.')
|
||||
|
||||
@force_not_colorized
|
||||
def testLongOutputSubTestSuccess(self):
|
||||
classname = f'{__name__}.{self.Test.__qualname__}'
|
||||
self.assertEqual(self._run_test('testSubTestSuccess', 2),
|
||||
f'testSubTestSuccess ({classname}.testSubTestSuccess) ... ok\n')
|
||||
|
||||
@force_not_colorized
|
||||
def testDotsOutputSubTestMixed(self):
|
||||
self.assertEqual(self._run_test('testSubTestMixed', 1), 'sFE')
|
||||
|
||||
@force_not_colorized
|
||||
def testLongOutputSubTestMixed(self):
|
||||
classname = f'{__name__}.{self.Test.__qualname__}'
|
||||
self.assertEqual(self._run_test('testSubTestMixed', 2),
|
||||
|
@ -675,7 +662,6 @@ class Test_TextTestResult(unittest.TestCase):
|
|||
f' testSubTestMixed ({classname}.testSubTestMixed) [fail] (c=3) ... FAIL\n'
|
||||
f' testSubTestMixed ({classname}.testSubTestMixed) [error] (d=4) ... ERROR\n')
|
||||
|
||||
@force_not_colorized
|
||||
def testDotsOutputTearDownFail(self):
|
||||
out = self._run_test('testSuccess', 1, AssertionError('fail'))
|
||||
self.assertEqual(out, 'F')
|
||||
|
@ -686,7 +672,6 @@ class Test_TextTestResult(unittest.TestCase):
|
|||
out = self._run_test('testSkip', 1, AssertionError('fail'))
|
||||
self.assertEqual(out, 'sF')
|
||||
|
||||
@force_not_colorized
|
||||
def testLongOutputTearDownFail(self):
|
||||
classname = f'{__name__}.{self.Test.__qualname__}'
|
||||
out = self._run_test('testSuccess', 2, AssertionError('fail'))
|
||||
|
|
|
@ -4,7 +4,6 @@ import sys
|
|||
import pickle
|
||||
import subprocess
|
||||
from test import support
|
||||
from test.support import force_not_colorized
|
||||
|
||||
import unittest
|
||||
from unittest.case import _Outcome
|
||||
|
@ -107,7 +106,7 @@ class TestCleanUp(unittest.TestCase):
|
|||
self.assertTrue(test.doCleanups())
|
||||
self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))])
|
||||
|
||||
@force_not_colorized
|
||||
@support.force_not_colorized
|
||||
def testCleanUpWithErrors(self):
|
||||
class TestableTest(unittest.TestCase):
|
||||
def testNothing(self):
|
||||
|
@ -251,6 +250,7 @@ class TestCleanUp(unittest.TestCase):
|
|||
self.assertEqual(test._cleanups, [])
|
||||
|
||||
|
||||
@support.force_not_colorized_test_class
|
||||
class TestClassCleanup(unittest.TestCase):
|
||||
def test_addClassCleanUp(self):
|
||||
class TestableTest(unittest.TestCase):
|
||||
|
@ -418,7 +418,6 @@ class TestClassCleanup(unittest.TestCase):
|
|||
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):
|
||||
|
@ -442,7 +441,6 @@ class TestClassCleanup(unittest.TestCase):
|
|||
['setUpClass', 'setUp', 'cleanup_exc',
|
||||
'tearDownClass', 'cleanup_good'])
|
||||
|
||||
@force_not_colorized
|
||||
def test_run_with_errors_addClassCleanUp(self):
|
||||
ordering = []
|
||||
class TestableTest(unittest.TestCase):
|
||||
|
@ -466,7 +464,6 @@ class TestClassCleanup(unittest.TestCase):
|
|||
['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
|
||||
|
@ -519,7 +516,6 @@ class TestClassCleanup(unittest.TestCase):
|
|||
['setUpClass', 'setUp', 'tearDownClass',
|
||||
'cleanup_exc'])
|
||||
|
||||
@force_not_colorized
|
||||
def test_with_errors_in_tearDownClass(self):
|
||||
ordering = []
|
||||
class TestableTest(unittest.TestCase):
|
||||
|
@ -596,7 +592,6 @@ class TestClassCleanup(unittest.TestCase):
|
|||
'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
|
||||
|
@ -608,6 +603,7 @@ class TestClassCleanup(unittest.TestCase):
|
|||
self.assertIn("\nNO TESTS RAN\n", runner.stream.getvalue())
|
||||
|
||||
|
||||
@support.force_not_colorized_test_class
|
||||
class TestModuleCleanUp(unittest.TestCase):
|
||||
def test_add_and_do_ModuleCleanup(self):
|
||||
module_cleanups = []
|
||||
|
@ -670,7 +666,6 @@ class TestModuleCleanUp(unittest.TestCase):
|
|||
self.assertEqual(cleanups,
|
||||
[((1, 2), {'function': 'hello'})])
|
||||
|
||||
@force_not_colorized
|
||||
def test_run_module_cleanUp(self):
|
||||
blowUp = True
|
||||
ordering = []
|
||||
|
@ -810,7 +805,6 @@ class TestModuleCleanUp(unittest.TestCase):
|
|||
'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):
|
||||
|
@ -972,7 +966,6 @@ class TestModuleCleanUp(unittest.TestCase):
|
|||
self.assertEqual(cleanups,
|
||||
[((1, 2), {'function': 3, 'self': 4})])
|
||||
|
||||
@force_not_colorized
|
||||
def test_with_errors_in_addClassCleanup(self):
|
||||
ordering = []
|
||||
|
||||
|
@ -1006,7 +999,6 @@ class TestModuleCleanUp(unittest.TestCase):
|
|||
['setUpModule', 'setUpClass', 'test', 'tearDownClass',
|
||||
'cleanup_exc', 'tearDownModule', 'cleanup_good'])
|
||||
|
||||
@force_not_colorized
|
||||
def test_with_errors_in_addCleanup(self):
|
||||
ordering = []
|
||||
class Module(object):
|
||||
|
@ -1037,7 +1029,6 @@ class TestModuleCleanUp(unittest.TestCase):
|
|||
['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
|
||||
|
@ -1330,7 +1321,7 @@ class Test_TextTestRunner(unittest.TestCase):
|
|||
expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
|
||||
self.assertEqual(runner._makeResult(), expectedresult)
|
||||
|
||||
@force_not_colorized
|
||||
@support.force_not_colorized
|
||||
@support.requires_subprocess()
|
||||
def test_warnings(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue