0
0
Testing Fundamentalstesting~10 mins

Parallel test execution in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run tests in parallel using threads.

Testing Fundamentals
from concurrent.futures import ThreadPoolExecutor

def run_tests():
    with ThreadPoolExecutor(max_workers=[1]) as executor:
        executor.map(run_single_test, test_cases)
Drag options to blanks, or click blank then click option'
A5
B10
C1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 means no parallelism, only sequential execution.
Using 0 causes an error.
2fill in blank
medium

Complete the code to wait for all parallel tests to finish before proceeding.

Testing Fundamentals
futures = [executor.submit(run_single_test, test) for test in test_cases]
for future in [1]:
    future.result()
Drag options to blanks, or click blank then click option'
Aexecutor
Bresults
Ctest_cases
Dfutures
Attempts:
3 left
💡 Hint
Common Mistakes
Looping over test_cases instead of futures.
Using executor as iterable causes error.
3fill in blank
hard

Fix the error in the code to correctly run tests in parallel using multiprocessing.

Testing Fundamentals
from multiprocessing import Pool

def run_parallel_tests():
    with Pool([1]) as pool:
        results = pool.map(run_single_test, test_cases)
Drag options to blanks, or click blank then click option'
A4
B'4'
C-1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using zero or negative numbers causes errors.
Passing a string instead of an integer.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps test names to their results after parallel execution.

Testing Fundamentals
results = {test[1]: result for test, result in zip(test_cases, [2])}
Drag options to blanks, or click blank then click option'
A.name
Bresults
Cpool.map(run_single_test, test_cases)
D.id
Attempts:
3 left
💡 Hint
Common Mistakes
Using .id instead of .name for test identifier.
Using a variable that does not hold results.
5fill in blank
hard

Fill all three blanks to filter and run only failed tests in parallel, collecting their names and results.

Testing Fundamentals
failed_tests = [test for test in test_cases if test.status == [1]]
results = {test.[2]: res for test, res in zip(failed_tests, pool.[3](run_single_test, failed_tests))}
Drag options to blanks, or click blank then click option'
A'failed'
Bname
Cmap
D'passed'
Attempts:
3 left
💡 Hint
Common Mistakes
Filtering for 'passed' instead of 'failed'.
Using wrong attribute instead of 'name'.
Using pool.submit instead of pool.map.