Skip to content

Little help on how to use pytest as multithread #2241

Answered by mdmintz
AlexPaiva asked this question in Q&A
Discussion options

You must be logged in to vote

As mentioned here: #2097 (comment) ...

If you're looking to run multi-threaded tests in UC Mode with a proxy, here's the scoop:

Multi-threading in UC Mode is possible if you use pytest multi-threading provided by pytest-xdist.

You'll need to use command-line options for this format, eg --uc to activate UC Mode, -n4 (for 4 parallel processes, etc), and --proxy=user:pass@host:port to set proxy settings.

Below is a sample run command:

pytest --uc -n4

(Add --proxy=user:pass@host:port to include proxy settings.)

Here's a sample file that uses @pytest.mark.parametrize() to turn one test into four tests when run with pytest:

import pytest

@pytest.mark.parametrize("", [[]] * 4)
def test_multi_…

Replies: 2 comments 8 replies

Comment options

You must be logged in to vote
7 replies
@AlexPaiva
Comment options

@mdmintz
Comment options

@AlexPaiva
Comment options

@AlexPaiva
Comment options

@mdmintz
Comment options

Answer selected by mdmintz
Comment options

You must be logged in to vote
1 reply
@mdmintz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants