Merge pull request #36 from nicoddemus/auto-detect-flaky
Fix test_auto_detect_cpus flakyness
This commit is contained in:
@@ -353,18 +353,15 @@ def test_terminate_on_hangingnode(testdir):
|
||||
result.stdout.fnmatch_lines(["*killed*my*", ])
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason='see #30')
|
||||
def test_auto_detect_cpus(testdir, monkeypatch):
|
||||
import multiprocessing
|
||||
monkeypatch.setattr(multiprocessing, 'cpu_count', lambda: 3)
|
||||
count = multiprocessing.cpu_count()
|
||||
testdir.makeconftest("""
|
||||
def pytest_unconfigure(config):
|
||||
with open('cpus', 'w') as f:
|
||||
f.write('cpus = %s' % config.option.numprocesses)
|
||||
def pytest_configure(config):
|
||||
print("numprocesses: (%s)" % config.getoption("numprocesses"))
|
||||
""")
|
||||
testdir.inline_run('-n=auto')
|
||||
cpus_file = testdir.tmpdir.join('cpus')
|
||||
assert cpus_file.read() == 'cpus = 3'
|
||||
result = testdir.runpytest('-n=auto', '-s')
|
||||
result.stdout.fnmatch_lines(["*numprocesses: (%s)*" % count])
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="works if run outside test suite", run=False)
|
||||
|
||||
Reference in New Issue
Block a user