Add test, CHANGELOG and docs for auto-cpu detection PR
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
-------------------------
|
||||
|
||||
- release as wheel
|
||||
- "-n" option now can be set to "auto" for automatic detection of number
|
||||
of cpus in the host system. Thanks Suloev Dmitry for the PR.
|
||||
|
||||
1.12
|
||||
-------------------------
|
||||
|
||||
@@ -59,7 +59,8 @@ To send tests to multiple CPUs, type::
|
||||
py.test -n NUM
|
||||
|
||||
Especially for longer running tests or tests requiring
|
||||
a lot of IO this can lead to considerable speed ups.
|
||||
a lot of IO this can lead to considerable speed ups. This option can
|
||||
also be set to ``auto`` for automatic detection of the number of CPUs.
|
||||
|
||||
|
||||
Running tests in a Python subprocess
|
||||
|
||||
@@ -363,6 +363,19 @@ def test_terminate_on_hangingnode(testdir):
|
||||
])
|
||||
|
||||
|
||||
def test_auto_detect_cpus(testdir, monkeypatch):
|
||||
import multiprocessing
|
||||
monkeypatch.setattr(multiprocessing, 'cpu_count', lambda: 3)
|
||||
testdir.makeconftest("""
|
||||
def pytest_unconfigure(config):
|
||||
with open('cpus', 'w') as f:
|
||||
f.write('cpus = %s' % config.option.numprocesses)
|
||||
""")
|
||||
testdir.inline_run('-n=auto')
|
||||
cpus_file = testdir.tmpdir.join('cpus')
|
||||
assert cpus_file.read() == 'cpus = 3'
|
||||
|
||||
|
||||
@pytest.mark.xfail(reason="works if run outside test suite", run=False)
|
||||
def test_session_hooks(testdir):
|
||||
testdir.makeconftest("""
|
||||
|
||||
Reference in New Issue
Block a user