Skip to content

Commit 4b4e90a

Browse files
authored
bpo-35967: Baseline values for uname -p (GH-12824)
* 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.
1 parent 9a4b38f commit 4b4e90a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_platform.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import subprocess
44
import sys
55
import unittest
6+
import collections
7+
import contextlib
68
from unittest import mock
79

810
from test import support
@@ -160,6 +162,18 @@ def test_uname(self):
160162
self.assertEqual(res[4], res.machine)
161163
self.assertEqual(res[5], res.processor)
162164

165+
@unittest.skipIf(sys.platform in ['win32', 'OpenVMS'], "uname -p not used")
166+
def test_uname_processor(self):
167+
"""
168+
On some systems, the processor must match the output
169+
of 'uname -p'. See Issue 35967 for rationale.
170+
"""
171+
with contextlib.suppress(subprocess.CalledProcessError):
172+
self.assertEqual(
173+
platform.uname().processor,
174+
subprocess.check_output(['uname', '-p'], text=True).strip(),
175+
)
176+
163177
@unittest.skipUnless(sys.platform.startswith('win'), "windows only test")
164178
def test_uname_win32_ARCHITEW6432(self):
165179
# Issue 7860: make sure we get architecture from the correct variable

0 commit comments

Comments
 (0)