10000 bpo-45735: Promise the long-time truth that `args=list` works by CharlieZhao95 · Pull Request #30982 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-45735: Promise the long-time truth that args=list works #30982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Feb 26, 2022
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
Add test cases in Thread for checking the validity of list *args*.
  • Loading branch information
CharlieZhao95 committed Jan 27, 2022
commit d30897ce17cf6569acd338feaec07593619dc843
24 changes: 24 additions & 0 deletions Lib/test/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,30 @@ def func(): pass
thread = threading.Thread(target=func)
self.assertEqual(thread.name, "Thread-5 (func)")

def test_run_with_list_args(self):
"""
Using list or tuple as *args* in constructor could achieve the same effect.
"""
num_list = [1, 2]

def func_with_num_args(arg1, arg2):
self.assertEqual(arg1, num_list[0])
self.assertEqual(arg2, num_list[1])

str_list = ["str1", "str2"]

def func_with_str_args(arg1, arg2):
self.assertEqual(arg1, str_list[0])
self.assertEqual(arg2, str_list[1])

test_suits = [
[num_list, func_with_num_args],
[str_list, func_with_str_args],
]
for test_case in test_suits:
t = threading.Thread(target=test_case[1], args=test_case[0])
t.start()

@cpython_only
def test_disallow_instantiation(self):
# Ensure that the type disallows instantiation (bpo-43916)
Expand Down
0