aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2020-04-16 08:28:09 -0400
committerGitHub <noreply@github.com>2020-04-16 08:28:09 -0400
commit518835f3354d6672e61c9f52348c1e4a2533ea00 (patch)
tree870820aa95948c58a6616795f266c290f0432a65 /Lib/test
parent6a5bf15c71a1c101c28774ae714b58e8a65b130c (diff)
downloadcpython-518835f3354d6672e61c9f52348c1e4a2533ea00.tar.gz
cpython-518835f3354d6672e61c9f52348c1e4a2533ea00.zip
bpo-35967 resolve platform.processor late (GH-12239)
* Replace flag-flip indirection with direct inspection * Use any for simpler code * Avoid flag flip and set results directly. * Resolve processor in a single function. * Extract processor handling into a namespace (class) * Remove _syscmd_uname, unused * Restore platform.processor behavior to match prior expectation (reliant on uname -p in a subprocess). * Extract '_unknown_as_blank' function. * Override uname_result to resolve the processor late. * Add a test intended to capture the expected values from 'uname -p' * Instead of trying to keep track of all of the possible outputs on different systems (probably a fool's errand), simply assert that except for the known platform variance, uname().processor matches the output of 'uname -p' * Use a skipIf directive * Use contextlib.suppress to suppress the error. Inline strip call. * 📜🤖 Added by blurb_it. * Remove use of contextlib.suppress (it would fail with NameError if it had any effect). Rely on _unknown_as_blank to replace unknown with blank. Co-authored-by: blurb-it[bot] <blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_platform.py9
1 files changed, 2 insertions, 7 deletions
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 63215a06358..855304a68c2 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -4,7 +4,6 @@ import subprocess
import sys
import unittest
import collections
-import contextlib
from unittest import mock
from test import support
@@ -168,12 +167,8 @@ class PlatformTest(unittest.TestCase):
On some systems, the processor must match the output
of 'uname -p'. See Issue 35967 for rationale.
"""
- with contextlib.suppress(subprocess.CalledProcessError):
- expect = subprocess.check_output(['uname', '-p'], text=True).strip()
-
- if expect == 'unknown':
- expect = ''
-
+ proc_res = subprocess.check_output(['uname', '-p'], text=True).strip()
+ expect = platform._unknown_as_blank(proc_res)
self.assertEqual(platform.uname().processor, expect)
@unittest.skipUnless(sys.platform.startswith('win'), "windows only test")