Created
December 1, 2023 05:37
-
-
Save devops-school/f0471da2b38fe844a7bf13bdbc0c34ac to your computer and use it in GitHub Desktop.
Python Test Runners - pytest -n
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install pytest | |
# tests/test_parallel.py | |
import pytest | |
import time | |
@pytest.mark.parametrize("task_id", range(1, 6)) | |
def test_concurrent_task(task_id): | |
"""Simulate concurrent tasks that take some time to complete.""" | |
time.sleep(1) # Simulate a task that takes 1 second | |
assert True, f"Task {task_id} completed successfully." | |
def test_non_concurrent_task(): | |
"""A non-concurrent task.""" | |
assert True, "Non-concurrent task completed." | |
# pytest -n 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment