gh-112730: Make the test suite resilient to color-activation environment variables (#117672)

This commit is contained in:
Pablo Galindo Salgado 2024-04-24 21:25:22 +01:00 committed by GitHub
parent 59a4d52973
commit 345e1e04ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 89 additions and 16 deletions

View file

@ -12,7 +12,8 @@ from textwrap import dedent
from test.support import (captured_stderr, check_impl_detail,
cpython_only, gc_collect,
no_tracing, script_helper,
SuppressCrashReport)
SuppressCrashReport,
force_not_colorized)
from test.support.import_helper import import_module
from test.support.os_helper import TESTFN, unlink
from test.support.warnings_helper import check_warnings
@ -41,6 +42,7 @@ class BrokenStrException(Exception):
# XXX This is not really enough, each *operation* should be tested!
class ExceptionTests(unittest.TestCase):
def raise_catch(self, exc, excname):
@ -1994,6 +1996,7 @@ class AssertionErrorTests(unittest.TestCase):
_rc, _out, err = script_helper.assert_python_failure('-Wd', '-X', 'utf8', TESTFN)
return err.decode('utf-8').splitlines()
@force_not_colorized
def test_assertion_error_location(self):
cases = [
('assert None',
@ -2070,6 +2073,7 @@ class AssertionErrorTests(unittest.TestCase):
result = self.write_source(source)
self.assertEqual(result[-3:], expected)
@force_not_colorized
def test_multiline_not_highlighted(self):
cases = [
("""
@ -2102,6 +2106,7 @@ class AssertionErrorTests(unittest.TestCase):
class SyntaxErrorTests(unittest.TestCase):
@force_not_colorized
def test_range_of_offsets(self):
cases = [
# Basic range from 2->7