Merge remote-tracking branch 'upstream/master' into features

This commit is contained in:
Bruno Oliveira 2017-07-26 19:01:28 -03:00
commit 3d89905114
14 changed files with 47 additions and 20 deletions

View File

@ -120,6 +120,7 @@ Michael Birtwell
Michael Droettboom Michael Droettboom
Michael Seifert Michael Seifert
Michal Wajszczuk Michal Wajszczuk
Mihai Capotă
Mike Lundy Mike Lundy
Nathaniel Waisbrot Nathaniel Waisbrot
Ned Batchelder Ned Batchelder

View File

@ -34,13 +34,13 @@ If you are reporting a bug, please include:
* Your operating system name and version. * Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting, * Any details about your local setup that might be helpful in troubleshooting,
specifically Python interpreter version, specifically the Python interpreter version, installed libraries, and pytest
installed libraries and pytest version. version.
* Detailed steps to reproduce the bug. * Detailed steps to reproduce the bug.
If you can write a demonstration test that currently fails but should pass (xfail), If you can write a demonstration test that currently fails but should pass
that is a very useful commit to make as well, even if you can't find how (xfail), that is a very useful commit to make as well, even if you cannot
to fix the bug yet. fix the bug itself.
.. _fixbugs: .. _fixbugs:
@ -165,29 +165,30 @@ Short version
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
#. Fork the repository; #. Fork the repository;
#. Target ``master`` for bug-fix and doc changes; #. Target ``master`` for bugfixes and doc changes;
#. Target ``features`` for new features or functionality changes. #. Target ``features`` for new features or functionality changes.
#. Follow **PEP-8**. There's a ``tox`` command to help fixing it: ``tox -e fix-lint``. #. Follow **PEP-8**. There's a ``tox`` command to help fixing it: ``tox -e fix-lint``.
#. Tests are run using ``tox``:: #. Tests are run using ``tox``::
tox -e linting,py27,py36 tox -e linting,py27,py36
The test environments above are usually enough to to cover most cases locally. The test environments above are usually enough to cover most cases locally.
#. Write a ``changelog`` entry: ``changelog/2574.bugfix``, use issue id number and one of #. Write a ``changelog`` entry: ``changelog/2574.bugfix``, use issue id number
``bugfix``, ``removal``, ``feature``, ``vendor``, ``doc`` or ``trivial`` for the issue type. and one of ``bugfix``, ``removal``, ``feature``, ``vendor``, ``doc`` or
``trivial`` for the issue type.
#. Add yourself to ``AUTHORS`` file if not there yet, in alphabetical order. #. Add yourself to ``AUTHORS`` file if not there yet, in alphabetical order.
Long version Long version
~~~~~~~~~~~~ ~~~~~~~~~~~~
What is a "pull request"? It informs the project's core developers about the
What is a "pull request"? It informs project's core developers about the
changes you want to review and merge. Pull requests are stored on changes you want to review and merge. Pull requests are stored on
`GitHub servers <https://github.com/pytest-dev/pytest/pulls>`_. `GitHub servers <https://github.com/pytest-dev/pytest/pulls>`_.
Once you send a pull request, we can discuss its potential modifications and Once you send a pull request, we can discuss its potential modifications and
even add more commits to it later on. There's an excellent tutorial on how Pull Requests work in the even add more commits to it later on. There's an excellent tutorial on how Pull
Requests work in the
`GitHub Help Center <https://help.github.com/articles/using-pull-requests/>`_. `GitHub Help Center <https://help.github.com/articles/using-pull-requests/>`_.
Here is a simple overview, with pytest-specific bits: Here is a simple overview, with pytest-specific bits:

View File

@ -254,6 +254,11 @@ class EncodedFile(object):
data = ''.join(linelist) data = ''.join(linelist)
self.write(data) self.write(data)
@property
def name(self):
"""Ensure that file.name is a string."""
return repr(self.buffer)
def __getattr__(self, name): def __getattr__(self, name):
return getattr(object.__getattribute__(self, "buffer"), name) return getattr(object.__getattribute__(self, "buffer"), name)

View File

@ -916,8 +916,11 @@ class Testdir:
env['PYTHONPATH'] = os.pathsep.join(filter(None, [ env['PYTHONPATH'] = os.pathsep.join(filter(None, [
str(os.getcwd()), env.get('PYTHONPATH', '')])) str(os.getcwd()), env.get('PYTHONPATH', '')]))
kw['env'] = env kw['env'] = env
return subprocess.Popen(cmdargs,
stdout=stdout, stderr=stderr, **kw) popen = subprocess.Popen(cmdargs, stdin=subprocess.PIPE, stdout=stdout, stderr=stderr, **kw)
popen.stdin.close()
return popen
def run(self, *cmdargs): def run(self, *cmdargs):
"""Run a command with arguments. """Run a command with arguments.

View File

@ -425,9 +425,10 @@ class Module(main.File, PyCollector):
if e.allow_module_level: if e.allow_module_level:
raise raise
raise self.CollectError( raise self.CollectError(
"Using pytest.skip outside of a test is not allowed. If you are " "Using pytest.skip outside of a test is not allowed. "
"trying to decorate a test function, use the @pytest.mark.skip " "To decorate a test function, use the @pytest.mark.skip "
"or @pytest.mark.skipif decorators instead." "or @pytest.mark.skipif decorators instead, and to skip a "
"module use `pytestmark = pytest.mark.{skip,skipif}."
) )
self.config.pluginmanager.consider_module(mod) self.config.pluginmanager.consider_module(mod)
return mod return mod

View File

@ -382,4 +382,4 @@ def show_skipped(terminalreporter, lines):
reason = reason[9:] reason = reason[9:]
lines.append( lines.append(
"SKIP [%d] %s:%d: %s" % "SKIP [%d] %s:%d: %s" %
(num, fspath, lineno, reason)) (num, fspath, lineno + 1, reason))

1
changelog/2023.bugfix Normal file
View File

@ -0,0 +1 @@
Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for avoid unwanted interactive ``pdb``

1
changelog/2546.trivial Normal file
View File

@ -0,0 +1 @@
Improve error message for CollectError with skip/skipif.

1
changelog/2548.bugfix Normal file
View File

@ -0,0 +1 @@
Fix line number when reporting summary of skipped tests.

1
changelog/2555.bugfix Normal file
View File

@ -0,0 +1 @@
capture: ensure that EncodedFile.name is a string.

1
changelog/2620.trivial Normal file
View File

@ -0,0 +1 @@
Show multiple issue links in CHANGELOG entries.

View File

@ -13,7 +13,8 @@
{% if definitions[category]['showcontent'] %} {% if definitions[category]['showcontent'] %}
{% for text, values in sections[section][category]|dictsort(by='value') %} {% for text, values in sections[section][category]|dictsort(by='value') %}
- {{ text }}{% if category != 'vendor' %} (`{{ values[0] }} <https://github.com/pytest-dev/pytest/issues/{{ values[0][1:] }}>`_){% endif %} {% set issue_joiner = joiner(', ') %}
- {{ text }}{% if category != 'vendor' %} ({% for value in values|sort %}{{ issue_joiner() }}`{{ value }} <https://github.com/pytest-dev/pytest/issues/{{ value[1:] }}>`_{% endfor %}){% endif %}
{% endfor %} {% endfor %}

View File

@ -716,13 +716,21 @@ def test_dupfile(tmpfile):
assert nf not in flist assert nf not in flist
print(i, end="", file=nf) print(i, end="", file=nf)
flist.append(nf) flist.append(nf)
fname_open = flist[0].name
assert fname_open == repr(flist[0].buffer)
for i in range(5): for i in range(5):
f = flist[i] f = flist[i]
f.close() f.close()
fname_closed = flist[0].name
assert fname_closed == repr(flist[0].buffer)
assert fname_closed != fname_open
tmpfile.seek(0) tmpfile.seek(0)
s = tmpfile.read() s = tmpfile.read()
assert "01234" in repr(s) assert "01234" in repr(s)
tmpfile.close() tmpfile.close()
assert fname_closed == repr(flist[0].buffer)
def test_dupfile_on_bytesio(): def test_dupfile_on_bytesio():
@ -730,6 +738,7 @@ def test_dupfile_on_bytesio():
f = capture.safe_text_dupfile(io, "wb") f = capture.safe_text_dupfile(io, "wb")
f.write("hello") f.write("hello")
assert io.getvalue() == b"hello" assert io.getvalue() == b"hello"
assert 'BytesIO object' in f.name
def test_dupfile_on_textio(): def test_dupfile_on_textio():
@ -737,6 +746,7 @@ def test_dupfile_on_textio():
f = capture.safe_text_dupfile(io, "wb") f = capture.safe_text_dupfile(io, "wb")
f.write("hello") f.write("hello")
assert io.getvalue() == "hello" assert io.getvalue() == "hello"
assert not hasattr(f, 'name')
@contextlib.contextmanager @contextlib.contextmanager

View File

@ -708,7 +708,7 @@ def test_skipped_reasons_functional(testdir):
) )
result = testdir.runpytest('-rs') result = testdir.runpytest('-rs')
result.stdout.fnmatch_lines([ result.stdout.fnmatch_lines([
"*SKIP*2*conftest.py:3: test", "*SKIP*2*conftest.py:4: test",
]) ])
assert result.ret == 0 assert result.ret == 0