1

For parallel execution i am using pytest-parallel, it works but each test cases is executing twice

def test_2():
    assert 2==2

def test_3():
    assert 1 == 1

command used

pytest -v -s test_file.py --workers auto

What auto will do like trigger as many workers as tests (each worker per test case)

and the result

collected 2 items
pytest-parallel: 8 workers (processes), 1 test per worker (thread)

testing_parallel.py::test_2 PASSED
testing_parallel.py::test_2 PASSED
testing_parallel.py::test_3 PASSED
testing_parallel.py::test_3 PASSED

tried with --workers 2

collected 2 items
pytest-parallel: 2 workers (processes), 1 test per worker (thread)

testing_parallel.py::test_2
testing_parallel.py::test_3 PASSED
testing_parallel.py::test_2 PASSEDPASSED
testing_parallel.py::test_3 PASSED

Here only test cases are there but execution is twice for each test case

user3814582
  • 153
  • 2
  • 15

1 Answers1

2

Actually your tests are being executing only once.

Problem is that the logging is shown results twice.

If you try to put a print inside of your code you will see they will only appear once at the console.

def test_2():
    print("Im running test 2")
    assert 2==2

def test_3():
    print("Im running test 3")
    assert 1 == 1
Jaky Ruby
  • 1,409
  • 1
  • 7
  • 12