gh-136066: simplify platform._platform() (#136069)

This commit is contained in:
Bénédikt Tran 2025-06-29 09:56:52 +02:00 committed by GitHub
parent 30ba03ea8e
commit bd928a3035
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 17 deletions

View file

@ -133,6 +133,22 @@ class PlatformTest(unittest.TestCase):
for terse in (False, True):
res = platform.platform(aliased, terse)
def test__platform(self):
for src, res in [
('foo bar', 'foo_bar'),
(
'1/2\\3:4;5"6(7)8(7)6"5;4:3\\2/1',
'1-2-3-4-5-6-7-8-7-6-5-4-3-2-1'
),
('--', ''),
('-f', '-f'),
('-foo----', '-foo'),
('--foo---', '-foo'),
('---foo--', '-foo'),
]:
with self.subTest(src=src):
self.assertEqual(platform._platform(src), res)
def test_system(self):
res = platform.system()