fix various flakes issues and add "flakes" to tox tests
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
import pytest
|
|
||||||
import py
|
import py
|
||||||
import sys
|
|
||||||
|
|
||||||
class TestDistribution:
|
class TestDistribution:
|
||||||
def test_n1_pass(self, testdir):
|
def test_n1_pass(self, testdir):
|
||||||
@@ -194,7 +192,7 @@ class TestDistribution:
|
|||||||
assert dest.join(subdir.basename).check(dir=1)
|
assert dest.join(subdir.basename).check(dir=1)
|
||||||
|
|
||||||
def test_data_exchange(self, testdir):
|
def test_data_exchange(self, testdir):
|
||||||
c1 = testdir.makeconftest("""
|
testdir.makeconftest("""
|
||||||
# This hook only called on master.
|
# This hook only called on master.
|
||||||
def pytest_configure_node(node):
|
def pytest_configure_node(node):
|
||||||
node.slaveinput['a'] = 42
|
node.slaveinput['a'] = 42
|
||||||
@@ -251,7 +249,7 @@ class TestDistribution:
|
|||||||
|
|
||||||
def test_keyboard_interrupt_dist(self, testdir):
|
def test_keyboard_interrupt_dist(self, testdir):
|
||||||
# xxx could be refined to check for return code
|
# xxx could be refined to check for return code
|
||||||
p = testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
def test_sleep():
|
def test_sleep():
|
||||||
import time
|
import time
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
@@ -301,7 +299,7 @@ class TestDistEach:
|
|||||||
|
|
||||||
class TestTerminalReporting:
|
class TestTerminalReporting:
|
||||||
def test_pass_skip_fail(self, testdir):
|
def test_pass_skip_fail(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
import py
|
import py
|
||||||
def test_ok():
|
def test_ok():
|
||||||
pass
|
pass
|
||||||
@@ -323,7 +321,7 @@ class TestTerminalReporting:
|
|||||||
])
|
])
|
||||||
|
|
||||||
def test_fail_platinfo(self, testdir):
|
def test_fail_platinfo(self, testdir):
|
||||||
p = testdir.makepyfile("""
|
testdir.makepyfile("""
|
||||||
def test_func():
|
def test_func():
|
||||||
assert 0
|
assert 0
|
||||||
""")
|
""")
|
||||||
|
|||||||
@@ -12,9 +12,6 @@ def pytest_addoption(parser):
|
|||||||
|
|
||||||
def pytest_funcarg__specssh(request):
|
def pytest_funcarg__specssh(request):
|
||||||
return getspecssh(request.config)
|
return getspecssh(request.config)
|
||||||
def getgspecs(config):
|
|
||||||
return [execnet.XSpec(spec)
|
|
||||||
for spec in config.getvalueorskip("gspecs")]
|
|
||||||
|
|
||||||
# configuration information for tests
|
# configuration information for tests
|
||||||
def getgspecs(config):
|
def getgspecs(config):
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ from xdist.dsession import (
|
|||||||
EachScheduling,
|
EachScheduling,
|
||||||
report_collection_diff,
|
report_collection_diff,
|
||||||
)
|
)
|
||||||
from _pytest import main as outcome
|
|
||||||
import py
|
import py
|
||||||
import pytest
|
import pytest
|
||||||
import execnet
|
import execnet
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ class TestStatRecorder:
|
|||||||
|
|
||||||
def test_dirchange(self, tmpdir):
|
def test_dirchange(self, tmpdir):
|
||||||
tmp = tmpdir
|
tmp = tmpdir
|
||||||
hello = tmp.ensure("dir", "hello.py")
|
tmp.ensure("dir", "hello.py")
|
||||||
sd = StatRecorder([tmp])
|
sd = StatRecorder([tmp])
|
||||||
assert not sd.fil(tmp.join("dir"))
|
assert not sd.fil(tmp.join("dir"))
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from xdist.slavemanage import SlaveController, unserialize_report
|
|||||||
from xdist.remote import serialize_report
|
from xdist.remote import serialize_report
|
||||||
import execnet
|
import execnet
|
||||||
queue = py.builtin._tryimport("queue", "Queue")
|
queue = py.builtin._tryimport("queue", "Queue")
|
||||||
from py.builtin import print_
|
|
||||||
import marshal
|
import marshal
|
||||||
|
|
||||||
WAIT_TIMEOUT = 10.0
|
WAIT_TIMEOUT = 10.0
|
||||||
@@ -26,7 +25,7 @@ class SlaveSetup:
|
|||||||
use_callback = False
|
use_callback = False
|
||||||
|
|
||||||
def __init__(self, request):
|
def __init__(self, request):
|
||||||
self.testdir = testdir = request.getfuncargvalue("testdir")
|
self.testdir = request.getfuncargvalue("testdir")
|
||||||
self.request = request
|
self.request = request
|
||||||
self.events = queue.Queue()
|
self.events = queue.Queue()
|
||||||
|
|
||||||
@@ -140,7 +139,7 @@ class TestReportSerialization:
|
|||||||
|
|
||||||
class TestSlaveInteractor:
|
class TestSlaveInteractor:
|
||||||
def test_basic_collect_and_runtests(self, slave):
|
def test_basic_collect_and_runtests(self, slave):
|
||||||
p = slave.testdir.makepyfile("""
|
slave.testdir.makepyfile("""
|
||||||
def test_func():
|
def test_func():
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
@@ -170,7 +169,7 @@ class TestSlaveInteractor:
|
|||||||
assert 'slaveoutput' in ev.kwargs
|
assert 'slaveoutput' in ev.kwargs
|
||||||
|
|
||||||
def test_remote_collect_skip(self, slave):
|
def test_remote_collect_skip(self, slave):
|
||||||
p = slave.testdir.makepyfile("""
|
slave.testdir.makepyfile("""
|
||||||
import py
|
import py
|
||||||
py.test.skip("hello")
|
py.test.skip("hello")
|
||||||
""")
|
""")
|
||||||
@@ -187,7 +186,7 @@ class TestSlaveInteractor:
|
|||||||
assert not ev.kwargs['ids']
|
assert not ev.kwargs['ids']
|
||||||
|
|
||||||
def test_remote_collect_fail(self, slave):
|
def test_remote_collect_fail(self, slave):
|
||||||
p = slave.testdir.makepyfile("""aasd qwe""")
|
slave.testdir.makepyfile("""aasd qwe""")
|
||||||
slave.setup()
|
slave.setup()
|
||||||
ev = slave.popevent("collectionstart")
|
ev = slave.popevent("collectionstart")
|
||||||
assert not ev.kwargs
|
assert not ev.kwargs
|
||||||
@@ -201,7 +200,7 @@ class TestSlaveInteractor:
|
|||||||
assert not ev.kwargs['ids']
|
assert not ev.kwargs['ids']
|
||||||
|
|
||||||
def test_runtests_all(self, slave):
|
def test_runtests_all(self, slave):
|
||||||
p = slave.testdir.makepyfile("""
|
slave.testdir.makepyfile("""
|
||||||
def test_func(): pass
|
def test_func(): pass
|
||||||
def test_func2(): pass
|
def test_func2(): pass
|
||||||
""")
|
""")
|
||||||
@@ -228,7 +227,7 @@ class TestSlaveInteractor:
|
|||||||
def test_happy_run_events_converted(self, testdir, slave):
|
def test_happy_run_events_converted(self, testdir, slave):
|
||||||
py.test.xfail("implement a simple test for event production")
|
py.test.xfail("implement a simple test for event production")
|
||||||
assert not slave.use_callback
|
assert not slave.use_callback
|
||||||
p = slave.testdir.makepyfile("""
|
slave.testdir.makepyfile("""
|
||||||
def test_func():
|
def test_func():
|
||||||
pass
|
pass
|
||||||
""")
|
""")
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import py
|
import py
|
||||||
import os
|
|
||||||
import execnet
|
import execnet
|
||||||
from xdist.slavemanage import HostRSync, NodeManager
|
from xdist.slavemanage import HostRSync, NodeManager
|
||||||
|
|
||||||
@@ -108,7 +107,7 @@ class TestHRSync:
|
|||||||
return mysetup(request)
|
return mysetup(request)
|
||||||
|
|
||||||
def test_hrsync_filter(self, mysetup):
|
def test_hrsync_filter(self, mysetup):
|
||||||
source, dest = mysetup.source, mysetup.dest
|
source, _ = mysetup.source, mysetup.dest # noqa
|
||||||
source.ensure("dir", "file.txt")
|
source.ensure("dir", "file.txt")
|
||||||
source.ensure(".svn", "entries")
|
source.ensure(".svn", "entries")
|
||||||
source.ensure(".somedotfile", "moreentries")
|
source.ensure(".somedotfile", "moreentries")
|
||||||
@@ -139,7 +138,7 @@ class TestNodeManager:
|
|||||||
@py.test.mark.xfail
|
@py.test.mark.xfail
|
||||||
def test_rsync_roots_no_roots(self, testdir, mysetup):
|
def test_rsync_roots_no_roots(self, testdir, mysetup):
|
||||||
mysetup.source.ensure("dir1", "file1").write("hello")
|
mysetup.source.ensure("dir1", "file1").write("hello")
|
||||||
config = testdir.parseconfig(source)
|
config = testdir.parseconfig(mysetup.source)
|
||||||
nodemanager = NodeManager(config, ["popen//chdir=%s" % mysetup.dest])
|
nodemanager = NodeManager(config, ["popen//chdir=%s" % mysetup.dest])
|
||||||
#assert nodemanager.config.topdir == source == config.topdir
|
#assert nodemanager.config.topdir == source == config.topdir
|
||||||
nodemanager.makegateways()
|
nodemanager.makegateways()
|
||||||
@@ -194,11 +193,11 @@ class TestNodeManager:
|
|||||||
def test_rsyncignore(self, testdir, mysetup):
|
def test_rsyncignore(self, testdir, mysetup):
|
||||||
source, dest = mysetup.source, mysetup.dest
|
source, dest = mysetup.source, mysetup.dest
|
||||||
dir2 = source.ensure("dir1", "dir2", dir=1)
|
dir2 = source.ensure("dir1", "dir2", dir=1)
|
||||||
dir5 = source.ensure("dir5", "dir6", "bogus")
|
source.ensure("dir5", "dir6", "bogus")
|
||||||
dirf = source.ensure("dir5", "file")
|
source.ensure("dir5", "file")
|
||||||
dir2.ensure("hello")
|
dir2.ensure("hello")
|
||||||
dirfoo = source.ensure("foo", "bar")
|
source.ensure("foo", "bar")
|
||||||
dirbar = source.ensure("bar", "foo")
|
source.ensure("bar", "foo")
|
||||||
source.join("tox.ini").write(py.std.textwrap.dedent("""
|
source.join("tox.ini").write(py.std.textwrap.dedent("""
|
||||||
[pytest]
|
[pytest]
|
||||||
rsyncdirs = dir1 dir5
|
rsyncdirs = dir1 dir5
|
||||||
@@ -217,7 +216,7 @@ class TestNodeManager:
|
|||||||
assert not dest.join('bar').check()
|
assert not dest.join('bar').check()
|
||||||
|
|
||||||
def test_optimise_popen(self, testdir, mysetup):
|
def test_optimise_popen(self, testdir, mysetup):
|
||||||
source, dest = mysetup.source, mysetup.dest
|
source = mysetup.source
|
||||||
specs = ["popen"] * 3
|
specs = ["popen"] * 3
|
||||||
source.join("conftest.py").write("rsyncdirs = ['a']")
|
source.join("conftest.py").write("rsyncdirs = ['a']")
|
||||||
source.ensure('a', dir=1)
|
source.ensure('a', dir=1)
|
||||||
|
|||||||
7
tox.ini
7
tox.ini
@@ -1,5 +1,5 @@
|
|||||||
[tox]
|
[tox]
|
||||||
envlist=py26,py32,py33,py34,py27,py27-pexpect,py33-pexpect,py26,py26-old,py33-old
|
envlist=py26,py32,py33,py34,py27,py27-pexpect,py33-pexpect,py26,py26-old,py33-old,flakes
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
changedir=testing
|
changedir=testing
|
||||||
@@ -13,6 +13,11 @@ deps={[testenv]deps}
|
|||||||
deps={[testenv]deps}
|
deps={[testenv]deps}
|
||||||
pexpect
|
pexpect
|
||||||
|
|
||||||
|
[testenv:flakes]
|
||||||
|
changedir=
|
||||||
|
deps = pytest-flakes>=0.2
|
||||||
|
commands = py.test --flakes -m flakes testing xdist
|
||||||
|
|
||||||
[testenv:py26-old]
|
[testenv:py26-old]
|
||||||
deps=
|
deps=
|
||||||
pytest==2.4.2
|
pytest==2.4.2
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import sys
|
|
||||||
import difflib
|
import difflib
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
@@ -295,7 +294,7 @@ class DSession:
|
|||||||
self.slave_errordown(node, "keyboard-interrupt")
|
self.slave_errordown(node, "keyboard-interrupt")
|
||||||
return
|
return
|
||||||
crashitem = self.sched.remove_node(node)
|
crashitem = self.sched.remove_node(node)
|
||||||
#assert not crashitem, (crashitem, node)
|
assert not crashitem, (crashitem, node)
|
||||||
if self.shuttingdown and not self.sched.hasnodes():
|
if self.shuttingdown and not self.sched.hasnodes():
|
||||||
self.session_finished = True
|
self.session_finished = True
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class RemoteControl(object):
|
|||||||
result = self.runsession()
|
result = self.runsession()
|
||||||
failures, reports, collection_failed = result
|
failures, reports, collection_failed = result
|
||||||
if collection_failed:
|
if collection_failed:
|
||||||
reports = ["Collection failed, keeping previous failure set"]
|
pass # "Collection failed, keeping previous failure set"
|
||||||
else:
|
else:
|
||||||
uniq_failures = []
|
uniq_failures = []
|
||||||
for failure in failures:
|
for failure in failures:
|
||||||
@@ -109,7 +109,6 @@ def repr_pytest_looponfailinfo(failreports, rootdirs):
|
|||||||
|
|
||||||
def init_slave_session(channel, args, option_dict):
|
def init_slave_session(channel, args, option_dict):
|
||||||
import os, sys
|
import os, sys
|
||||||
import py
|
|
||||||
outchannel = channel.gateway.newchannel()
|
outchannel = channel.gateway.newchannel()
|
||||||
sys.stdout = sys.stderr = outchannel.makefile('w')
|
sys.stdout = sys.stderr = outchannel.makefile('w')
|
||||||
channel.send(outchannel)
|
channel.send(outchannel)
|
||||||
|
|||||||
@@ -128,6 +128,7 @@ def remote_initconfig(option_dict, args):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__channelexec__':
|
if __name__ == '__channelexec__':
|
||||||
|
channel = channel # noqa
|
||||||
# python3.2 is not concurrent import safe, so let's play it safe
|
# python3.2 is not concurrent import safe, so let's play it safe
|
||||||
# https://bitbucket.org/hpk42/pytest/issue/347/pytest-xdist-and-python-32
|
# https://bitbucket.org/hpk42/pytest/issue/347/pytest-xdist-and-python-32
|
||||||
if sys.version_info[:2] == (3,2):
|
if sys.version_info[:2] == (3,2):
|
||||||
|
|||||||
Reference in New Issue
Block a user