Factor out py.std
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
import os
|
||||||
import re
|
import re
|
||||||
|
import textwrap
|
||||||
|
|
||||||
import py
|
import py
|
||||||
import pytest
|
import pytest
|
||||||
@@ -54,8 +56,8 @@ class TestDistribution:
|
|||||||
def test_n1_skip(self, testdir):
|
def test_n1_skip(self, testdir):
|
||||||
p1 = testdir.makepyfile("""
|
p1 = testdir.makepyfile("""
|
||||||
def test_skip():
|
def test_skip():
|
||||||
import py
|
import pytest
|
||||||
py.test.skip("myreason")
|
pytest.skip("myreason")
|
||||||
""")
|
""")
|
||||||
result = testdir.runpytest(p1, "-n1")
|
result = testdir.runpytest(p1, "-n1")
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
@@ -78,7 +80,7 @@ class TestDistribution:
|
|||||||
def test_manytests_to_one_popen(self, testdir):
|
def test_manytests_to_one_popen(self, testdir):
|
||||||
p1 = testdir.makepyfile(
|
p1 = testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
import py
|
import pytest
|
||||||
def test_fail0():
|
def test_fail0():
|
||||||
assert 0
|
assert 0
|
||||||
def test_fail1():
|
def test_fail1():
|
||||||
@@ -86,7 +88,7 @@ class TestDistribution:
|
|||||||
def test_ok():
|
def test_ok():
|
||||||
pass
|
pass
|
||||||
def test_skip():
|
def test_skip():
|
||||||
py.test.skip("hello")
|
pytest.skip("hello")
|
||||||
""", )
|
""", )
|
||||||
result = testdir.runpytest(p1, "-v", '-d', '--tx=popen', '--tx=popen')
|
result = testdir.runpytest(p1, "-v", '-d', '--tx=popen', '--tx=popen')
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
@@ -124,7 +126,7 @@ class TestDistribution:
|
|||||||
def test_dist_ini_specified(self, testdir):
|
def test_dist_ini_specified(self, testdir):
|
||||||
p1 = testdir.makepyfile(
|
p1 = testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
import py
|
import pytest
|
||||||
def test_fail0():
|
def test_fail0():
|
||||||
assert 0
|
assert 0
|
||||||
def test_fail1():
|
def test_fail1():
|
||||||
@@ -132,7 +134,7 @@ class TestDistribution:
|
|||||||
def test_ok():
|
def test_ok():
|
||||||
pass
|
pass
|
||||||
def test_skip():
|
def test_skip():
|
||||||
py.test.skip("hello")
|
pytest.skip("hello")
|
||||||
""", )
|
""", )
|
||||||
testdir.makeini("""
|
testdir.makeini("""
|
||||||
[pytest]
|
[pytest]
|
||||||
@@ -145,13 +147,13 @@ class TestDistribution:
|
|||||||
])
|
])
|
||||||
assert result.ret == 1
|
assert result.ret == 1
|
||||||
|
|
||||||
@py.test.mark.xfail("sys.platform.startswith('java')", run=False)
|
@pytest.mark.xfail("sys.platform.startswith('java')", run=False)
|
||||||
def test_dist_tests_with_crash(self, testdir):
|
def test_dist_tests_with_crash(self, testdir):
|
||||||
if not hasattr(py.std.os, 'kill'):
|
if not hasattr(os, 'kill'):
|
||||||
py.test.skip("no os.kill")
|
pytest.skip("no os.kill")
|
||||||
|
|
||||||
p1 = testdir.makepyfile("""
|
p1 = testdir.makepyfile("""
|
||||||
import py
|
import pytest
|
||||||
def test_fail0():
|
def test_fail0():
|
||||||
assert 0
|
assert 0
|
||||||
def test_fail1():
|
def test_fail1():
|
||||||
@@ -159,7 +161,7 @@ class TestDistribution:
|
|||||||
def test_ok():
|
def test_ok():
|
||||||
pass
|
pass
|
||||||
def test_skip():
|
def test_skip():
|
||||||
py.test.skip("hello")
|
pytest.skip("hello")
|
||||||
def test_crash():
|
def test_crash():
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
@@ -299,7 +301,7 @@ class TestDistEach:
|
|||||||
assert not result.ret
|
assert not result.ret
|
||||||
result.stdout.fnmatch_lines(["*2 pass*"])
|
result.stdout.fnmatch_lines(["*2 pass*"])
|
||||||
|
|
||||||
@py.test.mark.xfail(
|
@pytest.mark.xfail(
|
||||||
run=False,
|
run=False,
|
||||||
reason="other python versions might not have py.test installed")
|
reason="other python versions might not have py.test installed")
|
||||||
def test_simple_diffoutput(self, testdir):
|
def test_simple_diffoutput(self, testdir):
|
||||||
@@ -307,7 +309,7 @@ class TestDistEach:
|
|||||||
for name in ("python2.5", "python2.6"):
|
for name in ("python2.5", "python2.6"):
|
||||||
interp = py.path.local.sysfind(name)
|
interp = py.path.local.sysfind(name)
|
||||||
if interp is None:
|
if interp is None:
|
||||||
py.test.skip("%s not found" % name)
|
pytest.skip("%s not found" % name)
|
||||||
interpreters.append(interp)
|
interpreters.append(interp)
|
||||||
|
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
@@ -330,11 +332,11 @@ class TestDistEach:
|
|||||||
class TestTerminalReporting:
|
class TestTerminalReporting:
|
||||||
def test_pass_skip_fail(self, testdir):
|
def test_pass_skip_fail(self, testdir):
|
||||||
testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import py
|
import pytest
|
||||||
def test_ok():
|
def test_ok():
|
||||||
pass
|
pass
|
||||||
def test_skip():
|
def test_skip():
|
||||||
py.test.skip("xx")
|
pytest.skip("xx")
|
||||||
def test_func():
|
def test_func():
|
||||||
assert 0
|
assert 0
|
||||||
""")
|
""")
|
||||||
@@ -421,7 +423,7 @@ def test_teardownfails_one_function(testdir):
|
|||||||
["*def teardown_function(function):*", "*1 passed*1 error*"])
|
["*def teardown_function(function):*", "*1 passed*1 error*"])
|
||||||
|
|
||||||
|
|
||||||
@py.test.mark.xfail
|
@pytest.mark.xfail
|
||||||
def test_terminate_on_hangingnode(testdir):
|
def test_terminate_on_hangingnode(testdir):
|
||||||
p = testdir.makeconftest("""
|
p = testdir.makeconftest("""
|
||||||
def pytest_sessionfinish(session):
|
def pytest_sessionfinish(session):
|
||||||
@@ -585,7 +587,7 @@ def test_skipping(testdir):
|
|||||||
|
|
||||||
def test_issue34_pluginloading_in_subprocess(testdir):
|
def test_issue34_pluginloading_in_subprocess(testdir):
|
||||||
testdir.tmpdir.join("plugin123.py").write(
|
testdir.tmpdir.join("plugin123.py").write(
|
||||||
py.code.Source("""
|
textwrap.dedent("""
|
||||||
def pytest_namespace():
|
def pytest_namespace():
|
||||||
return {'sample_variable': 'testing'}
|
return {'sample_variable': 'testing'}
|
||||||
"""))
|
"""))
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import py
|
import py
|
||||||
|
import pprint
|
||||||
import pytest
|
import pytest
|
||||||
from xdist.workermanage import WorkerController, unserialize_report
|
from xdist.workermanage import WorkerController, unserialize_report
|
||||||
from xdist.remote import serialize_report
|
from xdist.remote import serialize_report
|
||||||
@@ -14,7 +15,7 @@ def check_marshallable(d):
|
|||||||
try:
|
try:
|
||||||
marshal.dumps(d)
|
marshal.dumps(d)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
py.std.pprint.pprint(d)
|
pprint.pprint(d)
|
||||||
raise ValueError("not marshallable")
|
raise ValueError("not marshallable")
|
||||||
|
|
||||||
|
|
||||||
@@ -344,7 +345,7 @@ class TestWorkerInteractor:
|
|||||||
for data in worker.slp.channel:
|
for data in worker.slp.channel:
|
||||||
worker.slp.process_from_remote(data)
|
worker.slp.process_from_remote(data)
|
||||||
worker.slp.process_from_remote(worker.slp.ENDMARK)
|
worker.slp.process_from_remote(worker.slp.ENDMARK)
|
||||||
py.std.pprint.pprint(hookrec.hookrecorder.calls)
|
pprint.pprint(hookrec.hookrecorder.calls)
|
||||||
hookrec.hookrecorder.contains([
|
hookrec.hookrecorder.contains([
|
||||||
("pytest_collectstart", "collector.fspath == aaa"),
|
("pytest_collectstart", "collector.fspath == aaa"),
|
||||||
("pytest_pycollect_makeitem", "name == 'test_func'"),
|
("pytest_pycollect_makeitem", "name == 'test_func'"),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import py
|
import py
|
||||||
import pytest
|
import pytest
|
||||||
|
import textwrap
|
||||||
import execnet
|
import execnet
|
||||||
from _pytest.pytester import HookRecorder
|
from _pytest.pytester import HookRecorder
|
||||||
from xdist import workermanage, newhooks
|
from xdist import workermanage, newhooks
|
||||||
@@ -198,7 +199,7 @@ class TestNodeManager:
|
|||||||
source.ensure("dir1", "somefile", dir=1)
|
source.ensure("dir1", "somefile", dir=1)
|
||||||
dir2.ensure("hello")
|
dir2.ensure("hello")
|
||||||
source.ensure("bogusdir", "file")
|
source.ensure("bogusdir", "file")
|
||||||
source.join("tox.ini").write(py.std.textwrap.dedent("""
|
source.join("tox.ini").write(textwrap.dedent("""
|
||||||
[pytest]
|
[pytest]
|
||||||
rsyncdirs=dir1/dir2
|
rsyncdirs=dir1/dir2
|
||||||
"""))
|
"""))
|
||||||
@@ -217,7 +218,7 @@ class TestNodeManager:
|
|||||||
dir2.ensure("hello")
|
dir2.ensure("hello")
|
||||||
source.ensure("foo", "bar")
|
source.ensure("foo", "bar")
|
||||||
source.ensure("bar", "foo")
|
source.ensure("bar", "foo")
|
||||||
source.join("tox.ini").write(py.std.textwrap.dedent("""
|
source.join("tox.ini").write(textwrap.dedent("""
|
||||||
[pytest]
|
[pytest]
|
||||||
rsyncdirs = dir1 dir5
|
rsyncdirs = dir1 dir5
|
||||||
rsyncignore = dir1/dir2 dir5/dir6 foo*
|
rsyncignore = dir1/dir2 dir5/dir6 foo*
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import py
|
import py
|
||||||
import pytest
|
import pytest
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import execnet
|
import execnet
|
||||||
|
|
||||||
|
|
||||||
@@ -228,7 +229,7 @@ class StatRecorder(object):
|
|||||||
changed = self.check()
|
changed = self.check()
|
||||||
if changed:
|
if changed:
|
||||||
return
|
return
|
||||||
py.std.time.sleep(checkinterval)
|
time.sleep(checkinterval)
|
||||||
|
|
||||||
def check(self, removepycfiles=True): # noqa, too complex
|
def check(self, removepycfiles=True): # noqa, too complex
|
||||||
changed = False
|
changed = False
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import fnmatch
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import threading
|
||||||
|
|
||||||
import py
|
import py
|
||||||
import pytest
|
import pytest
|
||||||
@@ -32,7 +33,7 @@ class NodeManager(object):
|
|||||||
|
|
||||||
def __init__(self, config, specs=None, defaultchdir="pyexecnetcache"):
|
def __init__(self, config, specs=None, defaultchdir="pyexecnetcache"):
|
||||||
self.config = config
|
self.config = config
|
||||||
self._nodesready = py.std.threading.Event()
|
self._nodesready = threading.Event()
|
||||||
self.trace = self.config.trace.get("nodemanager")
|
self.trace = self.config.trace.get("nodemanager")
|
||||||
self.group = execnet.Group()
|
self.group = execnet.Group()
|
||||||
if specs is None:
|
if specs is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user