Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Convert shlex call to an array of flags
  • Loading branch information
Harry-Lees committed Mar 24, 2025
commit a5dcbf25c228c6fdc9ff9252f325e5169d75133e
21 changes: 10 additions & 11 deletions Lib/test/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import itertools
import pickle
Comment thread
Harry-Lees marked this conversation as resolved.
import platform
import shlex
import subprocess
import sys
Comment thread
Harry-Lees marked this conversation as resolved.
import unittest
from unittest import mock
from textwrap import dedent
Comment thread
Harry-Lees marked this conversation as resolved.
Outdated
Comment thread
Harry-Lees marked this conversation as resolved.
Outdated
from unittest import mock

from test import support
from test.support import os_helper
Expand Down Expand Up @@ -789,19 +788,19 @@ def test_arg_parsing(self):
# `platform.platform()` call. The parameters are two booleans for `aliased`
# and `terse`.
options = (
("--nonaliased", (False, False)),
("nonaliased", (False, False)),
("--terse", (True, True)),
("terse", (True, True)),
("nonaliased terse", (False, True)),
("--nonaliased terse", (False, True)),
("--terse nonaliased", (False, True)),
(["--nonaliased"], (False, False)),
(["nonaliased"], (False, False)),
(["--terse"], (True, True)),
(["terse"], (True, True)),
(["nonaliased", "terse"], (False, True)),
(["--nonaliased", "terse"], (False, True)),
(["--terse", "nonaliased"], (False, True)),
)

for flags, args in options:
with self.subTest(f"{flags}, {args}"):
with self.subTest(flags=flags, args=args):
with mock.patch.object(platform, 'platform') as obj:
self.invoke_platform(*shlex.split(flags))
self.invoke_platform(*flags)
obj.assert_called_once_with(*args)

def test_help(self):
Expand Down