Make "-nX" and "--dist=loadscope" work properly together

This commit is contained in:
Bruno Oliveira
2017-08-02 21:12:26 -03:00
parent 43f7dbeb02
commit a7f8c22ae5
2 changed files with 4 additions and 3 deletions

View File

@@ -727,7 +727,7 @@ class TestLoadScope:
test_a=test_file,
test_b=test_file,
)
result = testdir.runpytest('--tx=2*popen', '--dist=loadscope', '-v')
result = testdir.runpytest('-n2', '--dist=loadscope', '-v')
assert get_workers_and_test_count_by_prefix('test_a.py::test', result.outlines) == {'gw0': 10}
assert get_workers_and_test_count_by_prefix('test_b.py::test', result.outlines) == {'gw1': 10}
@@ -744,7 +744,7 @@ class TestLoadScope:
def test(self, i):
pass
""")
result = testdir.runpytest('--tx=2*popen', '--dist=loadscope', '-v')
result = testdir.runpytest('-n2', '--dist=loadscope', '-v')
assert get_workers_and_test_count_by_prefix('test_a.py::TestA', result.outlines) == {'gw0': 10}
assert get_workers_and_test_count_by_prefix('test_a.py::TestB', result.outlines) == {'gw1': 10}

View File

@@ -98,7 +98,8 @@ def pytest_configure(config):
@pytest.mark.tryfirst
def pytest_cmdline_main(config):
if config.option.numprocesses:
config.option.dist = "load"
if config.option.dist == 'no':
config.option.dist = "load"
config.option.tx = ['popen'] * config.option.numprocesses
if config.option.distload:
config.option.dist = "load"