pytest repeat - get the current iteration number

I'm running some tests with pytest and I have to repeat the same test several times. I'm using the pytest-repeat module and it's working fine but I need to get the current iteration number and to...

Interleaved repeat of pytest

I have some tests which I would like to repeat a number of times. I tried the pytest-repeat plugin pip3 install pytest-repeat import pytest @pytest.mark.repeat(2) class TestDemo(): def...

How to capture the iteration number dyanmically inside test while using pytest-repeat

I'm executing my selenium script multiple times by using pytest-repeat. i need to capture the iteration number during execution and make use of it. I explored pytest.mark, pytest.collect &...

Excuting Pytest repeat plugin results to "No log output captured" in pytest html

As mentioned, I got https://i.stack.imgur.com/uAN9F.png If I don't use the repeat plugin, the logs are visible. But with the repeat plugin, the logs are missing. This is my command line: > pytest...

How to run a pytest method multiple times?

I am trying to run a pytest method multiple times using pytest-repeat but i am getting a warning and its running only once from page.to_run_login import RegisterLogin from utilites.testStatus...

Repeat a test upon an AssertionError

There is the module pytest-repeat which can be used to repeat the execution of pytest N times (the whole test suite). However, I want to, upon an AssertionError, re-run that specific test again,...

Updating global variable pytest

I need to have one of the variable updated for each run (I am using pytest-repeat to repeat the test n times). However, the variable is not getting updated. Here is my...

how to write integration tests using pytest and how to repeat the integration tests

I am new to this so please do not mind if the question is not specific enough. I want to know how to club unit tests into a single integration test in pytest. Furthermore, I would like to repeat...

Run pytest script simultaneously with different occurrence

I want to execute pytest script simultaneously with different occurrence Exemple for two Pytest script that I wish to run : Script 1 : test_print1.py ``` def test_print(config_file): assert...

Run python unittest until it fails

I have a Python unittest.TestCase that sometime fails. To debug this, I would like to run automatically run it until it fails. I found https://pypi.org/project/pytest-repeat/ which looks like...

How to repeat a test with pytest after every other test?

I have few test cases as described below. But i want to repeat test1() after every other test case. how can i achieve this? @pytest.mark.test1() @pytest.mark.parametrize(a,b,c) def test_test1(): ...

pytest : how to repeat all tests in test_file.py in sequence n times

I need to repeat all tests (having some parametrization) in a test_file.py in that specific sequence example : my test_file.py has ALL_NODES = [ 'a',...

How can I use pytest options as fixture and not repeat myself?

I have a test suite with a conftest.py defining some options and some fixtures to retrieve them: ``` def pytest_addoption(parser): parser.addoption("--ip", action="store") ...

pytest-variables: how get "variables" without declaring variables argument in test function prototype

I'm using pytest-variables (see https://github.com/pytest-dev/pytest-variables) to pass some variables by the command line as below: pytest **--variables** my_json_file. How can I get then this...

pytest - test flow order

I have a pytest code similar to below... if i run it with --count 3 it will run the test_first 3 times then test_second 3 times. What if i would like it to run test_first, test_second and repeat...

pytest parameters execution order for repeated test seems to be wrong

I am trying to run a test repeatedly which is a paramertrized. it doesn't seem to follow the order while executing test. I tried using pytest-repeat and pytest.mark.parametrize but i still didn't...

Need order and action of pytest hooks execution

Can anyone clarify how pytest hooks executes and what it does in each step? Mainly, could you please tell me why pytest_plugin_registered is repeated under pytest_sessionstart?. I checked...

Repeat test in pytest but regard all repetitions together as one test only

I want to repeat a test and it should fail if one of those repetitions fails. So basically: def test_example(): for _ in range(5): assert random.randint(0, 1) Is there a better way to...

pycharm pytest hangs with python subprocess.run() using bash in interactive mode

I want to test a subprocess call in python that uses the interactive shell in linux. The interactive shell is necessary in order to utilise the aliases and path links in .bashrc. In pycharm,...

execute several times a test with pytest

Is there a way to run a test x times with py.test? What I'm looking for it's to repeat a test several times, because the tests has random fixtures. Something like py.test -n100 I've been playing...

pytest: execute an action once in a module containing multiple tests

I have a pytest module that contains a class; this class subclass from Unit tests and I use pytest to run each user case in the class. class myclass(unittest.TestCase) #vars and such def...

How can I make a factory for class-scope fixtures with pytest?

I have a set of fixtures that all do the same thing, open up a json file and make it available to a test class. @pytest.fixture(scope="class") def category_params(request): base_path...

pytest-selenium: pytest_selenium_capture_debug hook is not fired on test failure

I make e2e tests for an web app by using pytest and selenium. Everything is fine, but one thing I can't figure out though spent day searching the web. I can't make pytest_selenium_capture_debug...

Repeat unittest every 3 minutes

I am working on a web monitor script that will just run through some pages and check that everything is displayed via selenium. I have everything setup and working and the only thing I need to do...

subprocess.Popen("pytest") returns 2 although pytest returns 1

I'm running pytest from a subprocess.Popen. As can be seen from the code below and it's output, the pytest exits with exit code 1 but the process thinks it exited with exit code 2. Why? (currently...

Test case Code coverage using Coverage.py and Pytest

I'm trying to get the executed code out of each Pytest Test case -in order to make a debuger-, now it's possible in Coverage module apis i will use the following code: cov.start() assert...

Is there a way to add custom CLI arguments to pytest using the same syntax as would be used with the argparse module?

TLDR: I want to extent pytest's cli and I know how that can be done using their own API, but I was just wondering if there was a way to do so using the argparse module directly (or its syntax at...

Running parameterized pytests in a loop

I am trying to run the pytest in a loop on parameterized data @pytest.mark.repeat(2) @pytest.mark.parametrize("username, password",[('[email protected]','aaa'), ...

Can we pass conditional parameters to fixture functions in pytest?

I want to pass a list as a parameter to fixture based on a if condition. Is there a way to do this? For example, please see the following code. What I want to achieve is that if I pass odd as the...

Why is Pytest in an infinite loop when mocking `builtins.input`?

I want to test a function which calls builtins.input, so I have monkeypatched it. However, this seems to give an error which seems to repeat forever. What is going on? Here is a test which...