[Python-modules-commits] [pytest] 01/07: Import pytest_3.2.0.orig.tar.gz
Sebastian Ramacher
sramacher at moszumanska.debian.org
Sun Aug 6 23:16:49 UTC 2017
This is an automated email from the git hooks/post-receive script.
sramacher pushed a commit to branch master
in repository pytest.
commit a287af18dc26f9dac41517ef7d2a7f754eb6331f
Author: Sebastian Ramacher <sramacher at debian.org>
Date: Mon Aug 7 01:16:08 2017 +0200
Import pytest_3.2.0.orig.tar.gz
---
.travis.yml | 11 +-
AUTHORS | 9 +
CHANGELOG.rst | 166 ++++++++
CONTRIBUTING.rst | 73 +++-
PKG-INFO | 2 +-
_pytest/_argcomplete.py | 7 +-
_pytest/_code/_py2traceback.py | 5 +-
_pytest/_code/code.py | 71 ++--
_pytest/_code/source.py | 46 +-
_pytest/_version.py | 2 +-
_pytest/assertion/__init__.py | 1 -
_pytest/assertion/rewrite.py | 29 +-
_pytest/assertion/util.py | 26 +-
_pytest/cacheprovider.py | 59 ++-
_pytest/capture.py | 34 +-
_pytest/compat.py | 32 +-
_pytest/config.py | 96 +++--
_pytest/debugging.py | 2 +-
_pytest/deprecated.py | 17 +-
_pytest/doctest.py | 38 +-
_pytest/fixtures.py | 91 ++--
_pytest/freeze_support.py | 1 -
_pytest/helpconfig.py | 45 +-
_pytest/hookspec.py | 78 +++-
_pytest/impl | 254 -----------
_pytest/junitxml.py | 12 +-
_pytest/main.py | 112 +++--
_pytest/mark.py | 116 +++++-
_pytest/monkeypatch.py | 6 +-
_pytest/nose.py | 5 +-
_pytest/outcomes.py | 140 +++++++
_pytest/pastebin.py | 8 +-
_pytest/pytester.py | 92 ++--
_pytest/python.py | 626 +++++-----------------------
_pytest/python_api.py | 616 +++++++++++++++++++++++++++
_pytest/recwarn.py | 7 +-
_pytest/resultlog.py | 13 +-
_pytest/runner.py | 206 +++------
_pytest/skipping.py | 74 ++--
_pytest/terminal.py | 75 ++--
_pytest/tmpdir.py | 4 +-
_pytest/unittest.py | 10 +-
_pytest/warnings.py | 12 +-
appveyor.yml | 2 +
changelog/_template.rst | 3 +-
doc/en/_templates/globaltoc.html | 1 +
doc/en/announce/index.rst | 1 +
doc/en/announce/release-3.2.0.rst | 48 +++
doc/en/builtin.rst | 28 +-
doc/en/cache.rst | 16 +-
doc/en/contact.rst | 5 +-
doc/en/contents.rst | 4 +-
doc/en/customize.rst | 72 +++-
doc/en/example/attic.rst | 2 +-
doc/en/example/index.rst | 4 +-
doc/en/example/markers.rst | 29 +-
doc/en/example/parametrize.rst | 6 +-
doc/en/example/reportingdemo.rst | 2 +-
doc/en/example/simple.rst | 43 +-
doc/en/fixture.rst | 16 +-
doc/en/getting-started.rst | 3 +-
doc/en/goodpractices.rst | 9 -
doc/en/historical-notes.rst | 177 ++++++++
doc/en/nose.rst | 2 +-
doc/en/parametrize.rst | 35 +-
doc/en/pythonpath.rst | 71 ++++
doc/en/setup.rst | 10 -
doc/en/skipping.rst | 61 ---
doc/en/unittest.rst | 16 +-
doc/en/usage.rst | 96 +++--
doc/en/warnings.rst | 34 ++
doc/en/writing_plugins.rst | 124 ++++--
pytest.egg-info/PKG-INFO | 2 +-
pytest.egg-info/SOURCES.txt | 8 +-
pytest.egg-info/requires.txt | 1 +
pytest.py | 6 +-
setup.py | 3 +-
testing/acceptance_test.py | 24 +-
testing/code/test_code.py | 24 +-
testing/code/test_excinfo.py | 152 ++++---
testing/code/test_source.py | 91 ++--
testing/code/test_source_multiline_block.py | 26 ++
testing/deprecated_test.py | 4 +
testing/freeze/create_executable.py | 1 -
testing/freeze/runtests_script.py | 2 +-
testing/freeze/tests/test_trivial.py | 3 +-
testing/freeze/tox_run.py | 2 +-
testing/python/approx.py | 292 ++++++++-----
testing/python/collect.py | 57 ++-
testing/python/fixture.py | 174 ++++++--
testing/python/integration.py | 8 +-
testing/python/metafunc.py | 165 +++++---
testing/python/raises.py | 1 -
testing/python/setup_only.py | 2 +-
testing/test_argcomplete.py | 29 +-
testing/test_assertion.py | 65 +--
testing/test_assertrewrite.py | 42 +-
testing/test_cache.py | 202 ++++++++-
testing/test_capture.py | 62 ++-
testing/test_collection.py | 79 +++-
testing/test_config.py | 20 +-
testing/test_conftest.py | 81 ++--
testing/test_doctest.py | 36 +-
testing/test_helpconfig.py | 9 +-
testing/test_junitxml.py | 4 +-
testing/test_mark.py | 74 +++-
testing/test_monkeypatch.py | 3 +-
testing/test_nose.py | 10 +
testing/test_parseopt.py | 29 +-
testing/test_pastebin.py | 7 +-
testing/test_pdb.py | 16 +-
testing/test_pluginmanager.py | 12 +-
testing/test_pytester.py | 4 +
testing/test_recwarn.py | 35 +-
testing/test_resultlog.py | 20 +-
testing/test_runner.py | 137 ++++--
testing/test_runner_xunit.py | 14 +-
testing/test_session.py | 24 +-
testing/test_skipping.py | 29 +-
testing/test_terminal.py | 72 +++-
testing/test_tmpdir.py | 5 +
testing/test_unittest.py | 144 ++++---
testing/test_warnings.py | 39 +-
tox.ini | 223 +++++-----
124 files changed, 4351 insertions(+), 2472 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 0a71e7d..6d8d583 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,18 +11,17 @@ env:
- TOXENV=coveralls
# note: please use "tox --listenvs" to populate the build matrix below
- TOXENV=linting
- - TOXENV=py26
- TOXENV=py27
- - TOXENV=py33
- TOXENV=py34
- TOXENV=py35
- - TOXENV=pypy
- TOXENV=py27-pexpect
- TOXENV=py27-xdist
- TOXENV=py27-trial
+ - TOXENV=py27-numpy
- TOXENV=py35-pexpect
- TOXENV=py35-xdist
- TOXENV=py35-trial
+ - TOXENV=py35-numpy
- TOXENV=py27-nobyte
- TOXENV=doctesting
- TOXENV=freeze
@@ -30,6 +29,12 @@ env:
matrix:
include:
+ - env: TOXENV=py26
+ python: '2.6'
+ - env: TOXENV=py33
+ python: '3.3'
+ - env: TOXENV=pypy
+ python: 'pypy-5.4'
- env: TOXENV=py36
python: '3.6'
- env: TOXENV=py37
diff --git a/AUTHORS b/AUTHORS
index ca28287..84833c6 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -9,6 +9,7 @@ Ahn Ki-Wook
Alexander Johnson
Alexei Kozlenok
Anatoly Bubenkoff
+Andras Tim
Andreas Zeidler
Andrzej Ostrowski
Andy Freeland
@@ -83,6 +84,7 @@ John Towler
Jon Sonesen
Jonas Obrist
Jordan Guymon
+Jordan Moldow
Joshua Bronson
Jurko Gospodnetić
Justyna Janczyszyn
@@ -90,13 +92,16 @@ Kale Kundert
Katarzyna Jachim
Kevin Cox
Kodi B. Arfer
+Lawrence Mitchell
Lee Kamentsky
Lev Maximov
+Llandy Riveron Del Risco
Loic Esteve
Lukas Bednar
Luke Murphy
Maciek Fijalkowski
Maho
+Maik Figura
Mandeep Bhutani
Manuel Krebber
Marc Schlaich
@@ -104,6 +109,7 @@ Marcin Bachry
Mark Abramowitz
Markus Unterwaditzer
Martijn Faassen
+Martin Altmayer
Martin K. Scherer
Martin Prusse
Mathieu Clabaut
@@ -117,7 +123,9 @@ Michael Birtwell
Michael Droettboom
Michael Seifert
Michal Wajszczuk
+Mihai Capotă
Mike Lundy
+Nathaniel Waisbrot
Ned Batchelder
Neven Mundar
Nicolas Delaby
@@ -165,3 +173,4 @@ Vitaly Lashmanov
Vlad Dragos
Wouter van Ackooy
Xuecong Liao
+Zoltán Máté
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 1c1185d..f033f8c 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -8,6 +8,172 @@
.. towncrier release notes start
+Pytest 3.2.0 (2017-07-30)
+=========================
+
+Deprecations and Removals
+-------------------------
+
+- ``pytest.approx`` no longer supports ``>``, ``>=``, ``<`` and ``<=``
+ operators to avoid surprising/inconsistent behavior. See `the docs
+ <https://docs.pytest.org/en/latest/builtin.html#pytest.approx>`_ for more
+ information. (`#2003 <https://github.com/pytest-dev/pytest/issues/2003>`_)
+
+- All old-style specific behavior in current classes in the pytest's API is
+ considered deprecated at this point and will be removed in a future release.
+ This affects Python 2 users only and in rare situations. (`#2147
+ <https://github.com/pytest-dev/pytest/issues/2147>`_)
+
+- A deprecation warning is now raised when using marks for parameters
+ in ``pytest.mark.parametrize``. Use ``pytest.param`` to apply marks to
+ parameters instead. (`#2427 <https://github.com/pytest-dev/pytest/issues/2427>`_)
+
+
+Features
+--------
+
+- Add support for numpy arrays (and dicts) to approx. (`#1994
+ <https://github.com/pytest-dev/pytest/issues/1994>`_)
+
+- Now test function objects have a ``pytestmark`` attribute containing a list
+ of marks applied directly to the test function, as opposed to marks inherited
+ from parent classes or modules. (`#2516 <https://github.com/pytest-
+ dev/pytest/issues/2516>`_)
+
+- Collection ignores local virtualenvs by default; `--collect-in-virtualenv`
+ overrides this behavior. (`#2518 <https://github.com/pytest-
+ dev/pytest/issues/2518>`_)
+
+- Allow class methods decorated as ``@staticmethod`` to be candidates for
+ collection as a test function. (Only for Python 2.7 and above. Python 2.6
+ will still ignore static methods.) (`#2528 <https://github.com/pytest-
+ dev/pytest/issues/2528>`_)
+
+- Introduce ``mark.with_args`` in order to allow passing functions/classes as
+ sole argument to marks. (`#2540 <https://github.com/pytest-
+ dev/pytest/issues/2540>`_)
+
+- New ``cache_dir`` ini option: sets the directory where the contents of the
+ cache plugin are stored. Directory may be relative or absolute path: if relative path, then
+ directory is created relative to ``rootdir``, otherwise it is used as is.
+ Additionally path may contain environment variables which are expanded during
+ runtime. (`#2543 <https://github.com/pytest-dev/pytest/issues/2543>`_)
+
+- Introduce the ``PYTEST_CURRENT_TEST`` environment variable that is set with
+ the ``nodeid`` and stage (``setup``, ``call`` and ``teardown``) of the test
+ being currently executed. See the `documentation
+ <https://docs.pytest.org/en/latest/example/simple.html#pytest-current-test-
+ environment-variable>`_ for more info. (`#2583 <https://github.com/pytest-
+ dev/pytest/issues/2583>`_)
+
+- Introduced ``@pytest.mark.filterwarnings`` mark which allows overwriting the
+ warnings filter on a per test, class or module level. See the `docs
+ <https://docs.pytest.org/en/latest/warnings.html#pytest-mark-
+ filterwarnings>`_ for more information. (`#2598 <https://github.com/pytest-
+ dev/pytest/issues/2598>`_)
+
+- ``--last-failed`` now remembers forever when a test has failed and only
+ forgets it if it passes again. This makes it easy to fix a test suite by
+ selectively running files and fixing tests incrementally. (`#2621
+ <https://github.com/pytest-dev/pytest/issues/2621>`_)
+
+- New ``pytest_report_collectionfinish`` hook which allows plugins to add
+ messages to the terminal reporting after collection has been finished
+ successfully. (`#2622 <https://github.com/pytest-dev/pytest/issues/2622>`_)
+
+- Added support for `PEP-415's <https://www.python.org/dev/peps/pep-0415/>`_
+ ``Exception.__suppress_context__``. Now if a ``raise exception from None`` is
+ caught by pytest, pytest will no longer chain the context in the test report.
+ The behavior now matches Python's traceback behavior. (`#2631
+ <https://github.com/pytest-dev/pytest/issues/2631>`_)
+
+- Exceptions raised by ``pytest.fail``, ``pytest.skip`` and ``pytest.xfail``
+ now subclass BaseException, making them harder to be caught unintentionally
+ by normal code. (`#580 <https://github.com/pytest-dev/pytest/issues/580>`_)
+
+
+Bug Fixes
+---------
+
+- Set ``stdin`` to a closed ``PIPE`` in ``pytester.py.Testdir.popen()`` for
+ avoid unwanted interactive ``pdb`` (`#2023 <https://github.com/pytest-
+ dev/pytest/issues/2023>`_)
+
+- Add missing ``encoding`` attribute to ``sys.std*`` streams when using
+ ``capsys`` capture mode. (`#2375 <https://github.com/pytest-
+ dev/pytest/issues/2375>`_)
+
+- Fix terminal color changing to black on Windows if ``colorama`` is imported
+ in a ``conftest.py`` file. (`#2510 <https://github.com/pytest-
+ dev/pytest/issues/2510>`_)
+
+- Fix line number when reporting summary of skipped tests. (`#2548
+ <https://github.com/pytest-dev/pytest/issues/2548>`_)
+
+- capture: ensure that EncodedFile.name is a string. (`#2555
+ <https://github.com/pytest-dev/pytest/issues/2555>`_)
+
+- The options ```--fixtures`` and ```--fixtures-per-test`` will now keep
+ indentation within docstrings. (`#2574 <https://github.com/pytest-
+ dev/pytest/issues/2574>`_)
+
+- doctests line numbers are now reported correctly, fixing `pytest-sugar#122
+ <https://github.com/Frozenball/pytest-sugar/issues/122>`_. (`#2610
+ <https://github.com/pytest-dev/pytest/issues/2610>`_)
+
+- Fix non-determinism in order of fixture collection. Adds new dependency
+ (ordereddict) for Python 2.6. (`#920 <https://github.com/pytest-
+ dev/pytest/issues/920>`_)
+
+
+Improved Documentation
+----------------------
+
+- Clarify ``pytest_configure`` hook call order. (`#2539
+ <https://github.com/pytest-dev/pytest/issues/2539>`_)
+
+- Extend documentation for testing plugin code with the ``pytester`` plugin.
+ (`#971 <https://github.com/pytest-dev/pytest/issues/971>`_)
+
+
+Trivial/Internal Changes
+------------------------
+
+- Update help message for ``--strict`` to make it clear it only deals with
+ unregistered markers, not warnings. (`#2444 <https://github.com/pytest-
+ dev/pytest/issues/2444>`_)
+
+- Internal code move: move code for pytest.approx/pytest.raises to own files in
+ order to cut down the size of python.py (`#2489 <https://github.com/pytest-
+ dev/pytest/issues/2489>`_)
+
+- Renamed the utility function ``_pytest.compat._escape_strings`` to
+ ``_ascii_escaped`` to better communicate the function's purpose. (`#2533
+ <https://github.com/pytest-dev/pytest/issues/2533>`_)
+
+- Improve error message for CollectError with skip/skipif. (`#2546
+ <https://github.com/pytest-dev/pytest/issues/2546>`_)
+
+- Emit warning about ``yield`` tests being deprecated only once per generator.
+ (`#2562 <https://github.com/pytest-dev/pytest/issues/2562>`_)
+
+- Ensure final collected line doesn't include artifacts of previous write.
+ (`#2571 <https://github.com/pytest-dev/pytest/issues/2571>`_)
+
+- Fixed all flake8 errors and warnings. (`#2581 <https://github.com/pytest-
+ dev/pytest/issues/2581>`_)
+
+- Added ``fix-lint`` tox environment to run automatic pep8 fixes on the code.
+ (`#2582 <https://github.com/pytest-dev/pytest/issues/2582>`_)
+
+- Turn warnings into errors in pytest's own test suite in order to catch
+ regressions due to deprecations more promptly. (`#2588
+ <https://github.com/pytest-dev/pytest/issues/2588>`_)
+
+- Show multiple issue links in CHANGELOG entries. (`#2620
+ <https://github.com/pytest-dev/pytest/issues/2620>`_)
+
+
Pytest 3.1.3 (2017-07-03)
=========================
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index edf71da..fa317fd 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -34,13 +34,13 @@ If you are reporting a bug, please include:
* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting,
- specifically Python interpreter version,
- installed libraries and pytest version.
+ specifically the Python interpreter version, installed libraries, and pytest
+ version.
* Detailed steps to reproduce the bug.
-If you can write a demonstration test that currently fails but should pass (xfail),
-that is a very useful commit to make as well, even if you can't find how
-to fix the bug yet.
+If you can write a demonstration test that currently fails but should pass
+(xfail), that is a very useful commit to make as well, even if you cannot
+fix the bug itself.
.. _fixbugs:
@@ -158,19 +158,40 @@ As stated, the objective is to share maintenance and avoid "plugin-abandon".
.. _`pull requests`:
.. _pull-requests:
-Preparing Pull Requests on GitHub
----------------------------------
+Preparing Pull Requests
+-----------------------
+
+Short version
+~~~~~~~~~~~~~
+
+#. Fork the repository;
+#. Target ``master`` for bugfixes and doc 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``.
+#. Tests are run using ``tox``::
+
+ tox -e linting,py27,py36
+
+ 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 ``bugfix``, ``removal``, ``feature``, ``vendor``, ``doc`` or
+ ``trivial`` for the issue type.
+#. Add yourself to ``AUTHORS`` file if not there yet, in alphabetical order.
-.. note::
- 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
- `GitHub servers <https://github.com/pytest-dev/pytest/pulls>`_.
- 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
-`GitHub Help Center <https://help.github.com/articles/using-pull-requests/>`_,
-but here is a simple overview:
+Long version
+~~~~~~~~~~~~
+
+What is a "pull request"? It informs the project's core developers about the
+changes you want to review and merge. Pull requests are stored on
+`GitHub servers <https://github.com/pytest-dev/pytest/pulls>`_.
+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
+`GitHub Help Center <https://help.github.com/articles/using-pull-requests/>`_.
+
+Here is a simple overview, with pytest-specific bits:
#. Fork the
`pytest GitHub repository <https://github.com/pytest-dev/pytest>`__. It's
@@ -214,12 +235,18 @@ but here is a simple overview:
This command will run tests via the "tox" tool against Python 2.7 and 3.6
and also perform "lint" coding-style checks.
-#. You can now edit your local working copy.
+#. You can now edit your local working copy. Please follow PEP-8.
You can now make the changes you want and run the tests again as necessary.
- To run tests on Python 2.7 and pass options to pytest (e.g. enter pdb on
- failure) to pytest you can do::
+ If you have too much linting errors, try running::
+
+ $ tox -e fix-lint
+
+ To fix pep8 related errors.
+
+ You can pass different options to ``tox``. For example, to run tests on Python 2.7 and pass options to pytest
+ (e.g. enter pdb on failure) to pytest you can do::
$ tox -e py27 -- --pdb
@@ -232,9 +259,11 @@ but here is a simple overview:
$ git commit -a -m "<commit message>"
$ git push -u
- Make sure you add a message to ``CHANGELOG.rst`` and add yourself to
- ``AUTHORS``. If you are unsure about either of these steps, submit your
- pull request and we'll help you fix it up.
+#. Create a new changelog entry in ``changelog``. The file should be named ``<issueid>.<type>``,
+ where *issueid* is the number of the issue related to the change and *type* is one of
+ ``bugfix``, ``removal``, ``feature``, ``vendor``, ``doc`` or ``trivial``.
+
+#. Add yourself to ``AUTHORS`` file if not there yet, in alphabetical order.
#. Finally, submit a pull request through the GitHub website using this data::
diff --git a/PKG-INFO b/PKG-INFO
index 2b08b6c..b0104f9 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pytest
-Version: 3.1.3
+Version: 3.2.0
Summary: pytest: simple powerful testing with Python
Home-page: http://pytest.org
Author: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others
diff --git a/_pytest/_argcomplete.py b/_pytest/_argcomplete.py
index 8c93e4c..1ba1ecc 100644
--- a/_pytest/_argcomplete.py
+++ b/_pytest/_argcomplete.py
@@ -62,14 +62,16 @@ import sys
import os
from glob import glob
+
class FastFilesCompleter:
'Fast file completer class'
+
def __init__(self, directories=True):
self.directories = directories
def __call__(self, prefix, **kwargs):
"""only called on non option completions"""
- if os.path.sep in prefix[1:]: #
+ if os.path.sep in prefix[1:]:
prefix_dir = len(os.path.dirname(prefix) + os.path.sep)
else:
prefix_dir = 0
@@ -98,5 +100,6 @@ if os.environ.get('_ARGCOMPLETE'):
def try_argcomplete(parser):
argcomplete.autocomplete(parser)
else:
- def try_argcomplete(parser): pass
+ def try_argcomplete(parser):
+ pass
filescompleter = None
diff --git a/_pytest/_code/_py2traceback.py b/_pytest/_code/_py2traceback.py
index d45ee01..5aacf0a 100644
--- a/_pytest/_code/_py2traceback.py
+++ b/_pytest/_code/_py2traceback.py
@@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function
import types
+
def format_exception_only(etype, value):
"""Format the exception part of a traceback.
@@ -30,7 +31,7 @@ def format_exception_only(etype, value):
# would throw another exception and mask the original problem.
if (isinstance(etype, BaseException) or
isinstance(etype, types.InstanceType) or
- etype is None or type(etype) is str):
+ etype is None or type(etype) is str):
return [_format_final_exc_line(etype, value)]
stype = etype.__name__
@@ -62,6 +63,7 @@ def format_exception_only(etype, value):
lines.append(_format_final_exc_line(stype, value))
return lines
+
def _format_final_exc_line(etype, value):
"""Return a list of a single line -- normal case for format_exception_only"""
valuestr = _some_str(value)
@@ -71,6 +73,7 @@ def _format_final_exc_line(etype, value):
line = "%s: %s\n" % (etype, valuestr)
return line
+
def _some_str(value):
try:
return unicode(value)
diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py
index 5b7cc41..0230c56 100644
--- a/_pytest/_code/code.py
+++ b/_pytest/_code/code.py
@@ -18,6 +18,7 @@ else:
class Code(object):
""" wrapper around Python code objects """
+
def __init__(self, rawcode):
if not hasattr(rawcode, "co_filename"):
rawcode = getrawcode(rawcode)
@@ -26,7 +27,7 @@ class Code(object):
self.firstlineno = rawcode.co_firstlineno - 1
self.name = rawcode.co_name
except AttributeError:
- raise TypeError("not a code object: %r" %(rawcode,))
+ raise TypeError("not a code object: %r" % (rawcode,))
self.raw = rawcode
def __eq__(self, other):
@@ -82,6 +83,7 @@ class Code(object):
argcount += raw.co_flags & CO_VARKEYWORDS
return raw.co_varnames[:argcount]
+
class Frame(object):
"""Wrapper around a Python frame holding f_locals and f_globals
in which expressions can be evaluated."""
@@ -119,7 +121,7 @@ class Frame(object):
"""
f_locals = self.f_locals.copy()
f_locals.update(vars)
- py.builtin.exec_(code, self.f_globals, f_locals )
+ py.builtin.exec_(code, self.f_globals, f_locals)
def repr(self, object):
""" return a 'safe' (non-recursive, one-line) string repr for 'object'
@@ -143,6 +145,7 @@ class Frame(object):
pass # this can occur when using Psyco
return retval
+
class TracebackEntry(object):
""" a single entry in a traceback """
@@ -168,7 +171,7 @@ class TracebackEntry(object):
return self.lineno - self.frame.code.firstlineno
def __repr__(self):
- return "<TracebackEntry %s:%d>" %(self.frame.code.path, self.lineno+1)
+ return "<TracebackEntry %s:%d>" % (self.frame.code.path, self.lineno + 1)
@property
def statement(self):
@@ -249,17 +252,19 @@ class TracebackEntry(object):
raise
except:
line = "???"
- return " File %r:%d in %s\n %s\n" %(fn, self.lineno+1, name, line)
+ return " File %r:%d in %s\n %s\n" % (fn, self.lineno + 1, name, line)
def name(self):
return self.frame.code.raw.co_name
name = property(name, None, None, "co_name of underlaying code")
+
class Traceback(list):
""" Traceback objects encapsulate and offer higher level
access to Traceback entries.
"""
Entry = TracebackEntry
+
def __init__(self, tb, excinfo=None):
""" initialize from given python traceback object and ExceptionInfo """
self._excinfo = excinfo
@@ -289,7 +294,7 @@ class Traceback(list):
(excludepath is None or not hasattr(codepath, 'relto') or
not codepath.relto(excludepath)) and
(lineno is None or x.lineno == lineno) and
- (firstlineno is None or x.frame.code.firstlineno == firstlineno)):
+ (firstlineno is None or x.frame.code.firstlineno == firstlineno)):
return Traceback(x._rawentry, self._excinfo)
return self
@@ -315,7 +320,7 @@ class Traceback(list):
""" return last non-hidden traceback entry that lead
to the exception of a traceback.
"""
- for i in range(-1, -len(self)-1, -1):
+ for i in range(-1, -len(self) - 1, -1):
entry = self[i]
if not entry.ishidden():
return entry
@@ -330,17 +335,17 @@ class Traceback(list):
# id for the code.raw is needed to work around
# the strange metaprogramming in the decorator lib from pypi
# which generates code objects that have hash/value equality
- #XXX needs a test
+ # XXX needs a test
key = entry.frame.code.path, id(entry.frame.code.raw), entry.lineno
- #print "checking for recursion at", key
+ # print "checking for recursion at", key
l = cache.setdefault(key, [])
if l:
f = entry.frame
loc = f.f_locals
for otherloc in l:
if f.is_true(f.eval(co_equal,
- __recursioncache_locals_1=loc,
- __recursioncache_locals_2=otherloc)):
+ __recursioncache_locals_1=loc,
+ __recursioncache_locals_2=otherloc)):
return i
l.append(entry.frame.f_locals)
return None
@@ -349,6 +354,7 @@ class Traceback(list):
co_equal = compile('__recursioncache_locals_1 == __recursioncache_locals_2',
'?', 'eval')
+
class ExceptionInfo(object):
""" wraps sys.exc_info() objects and offers
help for navigating the traceback.
@@ -405,10 +411,10 @@ class ExceptionInfo(object):
exconly = self.exconly(tryshort=True)
entry = self.traceback.getcrashentry()
path, lineno = entry.frame.code.raw.co_filename, entry.lineno
- return ReprFileLocation(path, lineno+1, exconly)
+ return ReprFileLocation(path, lineno + 1, exconly)
def getrepr(self, showlocals=False, style="long",
- abspath=False, tbfilter=True, funcargs=False):
+ abspath=False, tbfilter=True, funcargs=False):
""" return str()able representation of this exception info.
showlocals: show locals per traceback entry
style: long|short|no|native traceback style
@@ -425,7 +431,7 @@ class ExceptionInfo(object):
)), self._getreprcrash())
fmt = FormattedExcinfo(showlocals=showlocals, style=style,
- abspath=abspath, tbfilter=tbfilter, funcargs=funcargs)
+ abspath=abspath, tbfilter=tbfilter, funcargs=funcargs)
return fmt.repr_excinfo(self)
def __str__(self):
@@ -469,7 +475,7 @@ class FormattedExcinfo(object):
def _getindent(self, source):
# figure out indent for given source
try:
- s = str(source.getstatement(len(source)-1))
+ s = str(source.getstatement(len(source) - 1))
except KeyboardInterrupt:
raise
except:
@@ -513,7 +519,7 @@ class FormattedExcinfo(object):
for line in source.lines[:line_index]:
lines.append(space_prefix + line)
lines.append(self.flow_marker + " " + source.lines[line_index])
- for line in source.lines[line_index+1:]:
+ for line in source.lines[line_index + 1:]:
lines.append(space_prefix + line)
if excinfo is not None:
indent = 4 if short else self._getindent(source)
@@ -546,10 +552,10 @@ class FormattedExcinfo(object):
# _repr() function, which is only reprlib.Repr in
# disguise, so is very configurable.
str_repr = self._saferepr(value)
- #if len(str_repr) < 70 or not isinstance(value,
+ # if len(str_repr) < 70 or not isinstance(value,
# (list, tuple, dict)):
- lines.append("%-10s = %s" %(name, str_repr))
- #else:
+ lines.append("%-10s = %s" % (name, str_repr))
+ # else:
# self._line("%-10s =\\" % (name,))
# # XXX
# py.std.pprint.pprint(value, stream=self.excinfowriter)
@@ -575,14 +581,14 @@ class FormattedExcinfo(object):
s = self.get_source(source, line_index, excinfo, short=short)
lines.extend(s)
if short:
- message = "in %s" %(entry.name)
+ message = "in %s" % (entry.name)
else:
message = excinfo and excinfo.typename or ""
path = self._makepath(entry.path)
- filelocrepr = ReprFileLocation(path, entry.lineno+1, message)
+ filelocrepr = ReprFileLocation(path, entry.lineno + 1, message)
localsrepr = None
if not short:
- localsrepr = self.repr_locals(entry.locals)
+ localsrepr = self.repr_locals(entry.locals)
return ReprEntry(lines, reprargs, localsrepr, filelocrepr, style)
if excinfo:
lines.extend(self.get_exconly(excinfo, indent=4))
@@ -645,7 +651,7 @@ class FormattedExcinfo(object):
traceback = traceback[:recursionindex + 1]
else:
extraline = None
-
+
return traceback, extraline
def repr_excinfo(self, excinfo):
@@ -673,7 +679,7 @@ class FormattedExcinfo(object):
e = e.__cause__
excinfo = ExceptionInfo((type(e), e, e.__traceback__)) if e.__traceback__ else None
descr = 'The above exception was the direct cause of the following exception:'
- elif e.__context__ is not None:
+ elif (e.__context__ is not None and not e.__suppress_context__):
e = e.__context__
excinfo = ExceptionInfo((type(e), e, e.__traceback__)) if e.__traceback__ else None
descr = 'During handling of the above exception, another exception occurred:'
@@ -699,7 +705,7 @@ class TerminalRepr(object):
return io.getvalue().strip()
def __repr__(self):
- return "<%s instance at %0x>" %(self.__class__, id(self))
+ return "<%s instance at %0x>" % (self.__class__, id(self))
class ExceptionRepr(TerminalRepr):
@@ -743,6 +749,7 @@ class ReprExceptionInfo(ExceptionRepr):
self.reprtraceback.toterminal(tw)
super(ReprExceptionInfo, self).toterminal(tw)
+
class ReprTraceback(TerminalRepr):
entrysep = "_ "
@@ -758,7 +765,7 @@ class ReprTraceback(TerminalRepr):
tw.line("")
entry.toterminal(tw)
if i < len(self.reprentries) - 1:
- next_entry = self.reprentries[i+1]
+ next_entry = self.reprentries[i + 1]
if entry.style == "long" or \
entry.style == "short" and next_entry.style == "long":
tw.sep(self.entrysep)
@@ -766,12 +773,14 @@ class ReprTraceback(TerminalRepr):
if self.extraline:
tw.line(self.extraline)
+
class ReprTracebackNative(ReprTraceback):
def __init__(self, tblines):
self.style = "native"
self.reprentries = [ReprEntryNative(tblines)]
self.extraline = None
+
class ReprEntryNative(TerminalRepr):
style = "native"
@@ -781,6 +790,7 @@ class ReprEntryNative(TerminalRepr):
def toterminal(self, tw):
tw.write("".join(self.lines))
+
class ReprEntry(TerminalRepr):
localssep = "_ "
@@ -797,7 +807,7 @@ class ReprEntry(TerminalRepr):
for line in self.lines:
red = line.startswith("E ")
tw.line(line, bold=True, red=red)
- #tw.line("")
+ # tw.line("")
return
if self.reprfuncargs:
self.reprfuncargs.toterminal(tw)
@@ -805,7 +815,7 @@ class ReprEntry(TerminalRepr):
red = line.startswith("E ")
tw.line(line, bold=True, red=red)
if self.reprlocals:
- #tw.sep(self.localssep, "Locals")
+ # tw.sep(self.localssep, "Locals")
tw.line("")
self.reprlocals.toterminal(tw)
if self.reprfileloc:
@@ -818,6 +828,7 @@ class ReprEntry(TerminalRepr):
self.reprlocals,
self.reprfileloc)
+
class ReprFileLocation(TerminalRepr):
def __init__(self, path, lineno, message):
self.path = str(path)
@@ -834,6 +845,7 @@ class ReprFileLocation(TerminalRepr):
tw.write(self.path, bold=True, red=True)
tw.line(":%s: %s" % (self.lineno, msg))
+
class ReprLocals(TerminalRepr):
def __init__(self, lines):
self.lines = lines
@@ -842,6 +854,7 @@ class ReprLocals(TerminalRepr):
for line in self.lines:
tw.line(line)
+
class ReprFuncArgs(TerminalRepr):
def __init__(self, args):
self.args = args
@@ -850,11 +863,11 @@ class ReprFuncArgs(TerminalRepr):
if self.args:
linesofar = ""
for name, value in self.args:
- ns = "%s = %s" %(name, value)
+ ns = "%s = %s" % (name, value)
if len(ns) + len(linesofar) + 2 > tw.fullwidth:
if linesofar:
tw.line(linesofar)
- linesofar = ns
+ linesofar = ns
else:
if linesofar:
linesofar += ", " + ns
diff --git a/_pytest/_code/source.py b/_pytest/_code/source.py
index 8e61484..e21fecb 100644
--- a/_pytest/_code/source.py
+++ b/_pytest/_code/source.py
@@ -2,7 +2,8 @@ from __future__ import absolute_import, division, generators, print_function
from bisect import bisect_right
import sys
-import inspect, tokenize
+import inspect
+import tokenize
import py
cpy_compile = compile
@@ -19,6 +20,7 @@ class Source(object):
possibly deindenting it.
"""
_compilecounter = 0
+
def __init__(self, *parts, **kwargs):
self.lines = lines = []
de = kwargs.get('deindent', True)
@@ -73,7 +75,7 @@ class Source(object):
start, end = 0, len(self)
while start < end and not self.lines[start].strip():
start += 1
- while end > start and not self.lines[end-1].strip():
+ while end > start and not self.lines[end - 1].strip():
end -= 1
source = Source()
source.lines[:] = self.lines[start:end]
@@ -86,8 +88,8 @@ class Source(object):
before = Source(before)
after = Source(after)
newsource = Source()
- lines = [ (indent + line) for line in self.lines]
- newsource.lines = before.lines + lines + after.lines
+ lines = [(indent + line) for line in self.lines]
+ newsource.lines = before.lines + lines + after.lines
return newsource
def indent(self, indent=' ' * 4):
@@ -95,7 +97,7 @@ class Source(object):
all lines indented by the given indent-string.
"""
newsource = Source()
- newsource.lines = [(indent+line) for line in self.lines]
+ newsource.lines = [(indent + line) for line in self.lines]
return newsource
def getstatement(self, lineno, assertion=False):
@@ -134,7 +136,8 @@ class Source(object):
try:
import parser
except ImportError:
- syntax_checker = lambda x: compile(x, 'asd', 'exec')
+ def syntax_checker(x):
+ return compile(x, 'asd', 'exec')
else:
syntax_checker = parser.suite
@@ -143,8 +146,8 @@ class Source(object):
else:
source = str(self)
try:
- #compile(source+'\n', "x", "exec")
- syntax_checker(source+'\n')
+ # compile(source+'\n', "x", "exec")
+ syntax_checker(source + '\n')
except KeyboardInterrupt:
raise
except Exception:
@@ -164,8 +167,8 @@ class Source(object):
"""
if not filename or py.path.local(filename).check(file=0):
if _genframe is None:
- _genframe = sys._getframe(1) # the caller
- fn,lineno = _genframe.f_code.co_filename, _genframe.f_lineno
+ _genframe = sys._getframe(1) # the caller
+ fn, lineno = _genframe.f_code.co_filename, _genframe.f_lineno
base = "<%d-codegen " % self._compilecounter
self.__class__._compilecounter += 1
if not filename:
... 14328 lines suppressed ...
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/pytest.git
More information about the Python-modules-commits
mailing list