kevlened / pytest-parallel

A pytest plugin for parallel and concurrent testing
https://github.com/browsertron/pytest-parallel/issues/104#issuecomment-1293941066
MIT License
313 stars 60 forks source link

Py.Test Can't find pytest-parallel when invoked programatically #61

Closed gerosalesc closed 4 years ago

gerosalesc commented 4 years ago

Hi, I am trying to send parallel arguments to a programmatic invocation but pytest doesn't seem to find the arguments. But on the other hand, when I run py.test with a direct command line invocation including the same arguments, it will find and run parallel sucesfully.

ERROR: usage: invoke_pytest.py [options] [file_or_dir] [file_or_dir] [...] invoke_pytest.py: error: unrecognized arguments: --workers 1 --tests-per-worker 4

This is my code:

import os
import sys
import pytest

sys.path.append(os.path.join(sys.path[0], 'tests', 'bdd'))
sys.path.append(os.path.join(sys.path[0], 'tests', 'bdd', 'steps'))

pytest_args = [
    "tests/bdd",
    '--rootdir=tests/bdd',
    "--workers 1",
    "--tests-per-worker 4",
    '-k login',
    "--splinter-webdriver=remote",
    "--splinter-make-screenshot-on-failure=true",
    '--splinter-remote-url=...',
    '--cache-clear', '-v',
]
result = pytest.main(pytest_args)
print(f"RESULT {result}")

Although it seems unrelated, I am also using py.test bdd and splinter for this test suite.

gerosalesc commented 4 years ago

This is in fact an error on my side. I was trying to send an argument and value in the same position of the list but they should be split like this:

Wrong: "--tests-per-worker 4",

Use instead: "--tests-per-worker", "4",

I am closing this.