Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip progress display when in non-terminal #55

Merged
merged 4 commits into from
May 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,21 @@ install: "pip install -U tox setuptools_scm"
env:
matrix:
# note: please use "tox --listenvs" to populate the build matrix
- TESTENV=py26-pytest24
- TESTENV=py26-pytest25
- TESTENV=py26-pytest26
- TESTENV=py26-pytest27
- TESTENV=py26-pytest28
- TESTENV=py27-pytest24
- TESTENV=py27-pytest25
- TESTENV=py26-pytest29
- TESTENV=py27-pytest26
- TESTENV=py27-pytest27
- TESTENV=py27-pytest28
- TESTENV=py34-pytest24
- TESTENV=py34-pytest25
- TESTENV=py27-pytest29
- TESTENV=py34-pytest26
- TESTENV=py34-pytest27
- TESTENV=py34-pytest28
- TESTENV=py34-pytest29
- TESTENV=py35-pytest27
- TESTENV=py35-pytest28
- TESTENV=py35-pytest29
- TESTENV=py27-pytest28-pexpect
- TESTENV=py35-pytest28-pexpect
- TESTENV=flakes
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
- new ``worker_id`` fixture, returns the id of the worker in a test or fixture.
Thanks Jared Hellman for the PR.

- display progress during collection only when in a terminal, similar to pytest #1397 issue.
Thanks Bruno Oliveira for the PR.


1.14
----
Expand Down
22 changes: 22 additions & 0 deletions testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,3 +642,25 @@ def test_worker_id1(worker_id, run_num):
assert worker_ids == set(['master'])
else:
assert worker_ids == set(['gw0', 'gw1'])


def test_color_yes_collection_on_non_atty(testdir, request):
"""skip collect progress report when working on non-terminals.

Similar to pytest-dev/pytest#1397
"""
tr = request.config.pluginmanager.getplugin("terminalreporter")
if not hasattr(tr, 'isatty'):
pytest.skip('only valid for newer pytest versions')
testdir.makepyfile("""
import pytest
@pytest.mark.parametrize('i', range(10))
def test_this(i):
assert 1
""")
args = ['--color=yes', '-n2']
result = testdir.runpytest(*args)
assert 'test session starts' in result.stdout.str()
assert '\x1b[1m' in result.stdout.str()
assert 'gw0 [10] / gw1 [10]' in result.stdout.str()
assert 'gw0 C / gw1 C' not in result.stdout.str()
2 changes: 2 additions & 0 deletions testing/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import py
import pytest
from xdist.slavemanage import SlaveController, unserialize_report
from xdist.remote import serialize_report
import execnet
Expand Down Expand Up @@ -62,6 +63,7 @@ def pytest_funcarg__slave(request):
return SlaveSetup(request)


@pytest.mark.xfail(reason='#59')
def test_remoteinitconfig(testdir):
from xdist.remote import remote_initconfig
config1 = testdir.parseconfig()
Expand Down
12 changes: 6 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
# if you change the envlist, please update .travis.yml file as well
envlist=
py{26,27,34}-pytest2{4,5,6,7,8}
py35-pytest2{7,8}
py{26,27,34}-pytest2{6,7,8,9}
py35-pytest2{7,8,9}
py{27,35}-pytest28-pexpect
flakes
readme
Expand All @@ -13,12 +13,12 @@ changedir=testing
passenv = USER USERNAME
deps =
pycmd
setuptools_scm # to avoid .eggs
pytest24: pytest~=2.4.0
pytest25: pytest~=2.5.0
# to avoid .eggs
setuptools_scm
pytest26: pytest~=2.6.1
pytest27: pytest~=2.7.2
pytest28: pytest~=2.8.3
pytest28: pytest~=2.8.7
pytest29: pytest~=2.9.1
pexpect: pexpect
platform=
pexpect: linux|darwin
Expand Down
5 changes: 3 additions & 2 deletions xdist/dsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,17 +722,18 @@ def __init__(self, config):
self.tr = config.pluginmanager.getplugin("terminalreporter")
self._status = {}
self._lastlen = 0
self._isatty = getattr(self.tr, 'isatty', self.tr.hasmarkup)

def write_line(self, msg):
self.tr.write_line(msg)

def ensure_show_status(self):
if not self.tr.hasmarkup:
if not self._isatty:
self.write_line(self.getstatus())

def setstatus(self, spec, status, show=True):
self._status[spec.id] = status
if show and self.tr.hasmarkup:
if show and self._isatty:
self.rewrite(self.getstatus())

def getstatus(self):
Expand Down