bpo-32002: Refactor C locale coercion tests by ncoghlan · Pull Request #4369 · python/cpython

I still get the following failures on Cygwin:

======================================================================
FAIL: test_LC_ALL_set_to_C (test.test_c_locale_coercion.LocaleCoercionTests) (default_locale=True, PYTHONCOERCECLOCALE='warn')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/embray/src/python/cpython/Lib/test/test_c_locale_coercion.py", line 344, in _check_c_locale_coercion
    _coercion_expected)
  File "/home/embray/src/python/cpython/Lib/test/test_c_locale_coercion.py", line 235, in _check_child_encoding_details
    self.assertEqual(stderr_lines, expected_warnings)
AssertionError: Lists differ: ['Python runtime initialized with LC_CTYPE[192 chars]ed.'] != []

First list contains 1 additional elements.
First extra element 0:
'Python runtime initialized with LC_CTYPE=C (a locale with default ASCII encoding), which may cause Unicode compatibility problems. Using C.UTF-8, C.utf8, or UTF-8 (if available) as alternative Unicode-compatible locales is recommended.'

+ []
- ['Python runtime initialized with LC_CTYPE=C (a locale with default ASCII '
-  'encoding), which may cause Unicode compatibility problems. Using C.UTF-8, '
-  'C.utf8, or UTF-8 (if available) as alternative Unicode-compatible locales is '
-  'recommended.']

======================================================================
FAIL: test_PYTHONCOERCECLOCALE_set_to_zero (test.test_c_locale_coercion.LocaleCoercionTests) (default_locale=True, PYTHONCOERCECLOCALE='0')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/embray/src/python/cpython/Lib/test/test_c_locale_coercion.py", line 344, in _check_c_locale_coercion
    _coercion_expected)
  File "/home/embray/src/python/cpython/Lib/test/test_c_locale_coercion.py", line 232, in _check_child_encoding_details
    self.assertEqual(encoding_details, expected_details)
AssertionError: {'fsencoding': 'utf-8', 'stdin_info': 'utf-8:surrogateesc[123 chars]: ''} != {'fsencoding': 'ascii', 'stdin_info': 'ascii:surrogateesc[123 chars]: ''}
- {'fsencoding': 'utf-8',
?                 ^^^^^

+ {'fsencoding': 'ascii',
?                 ^^^^^

   'lang': '',
   'lc_all': '',
   'lc_ctype': '',
-  'stderr_info': 'utf-8:backslashreplace',
?                  ^^^^^

+  'stderr_info': 'ascii:backslashreplace',
?                  ^^^^^

-  'stdin_info': 'utf-8:surrogateescape',
?                 ^^^^^

+  'stdin_info': 'ascii:surrogateescape',
?                 ^^^^^

-  'stdout_info': 'utf-8:surrogateescape'}
?                  ^^^^^

+  'stdout_info': 'ascii:surrogateescape'}
?                  ^^^^^

But +1 to going ahead and merging, if you want, as this is significantly cleaned up, and I can look into addressing the final Cygwin-related bits on top of this.