[Python-modules-commits] [pytest] 01/07: Import pytest_3.0.5.orig.tar.gz

Sebastian Ramacher sramacher at moszumanska.debian.org
Fri Dec 9 16:57:26 UTC 2016


This is an automated email from the git hooks/post-receive script.

sramacher pushed a commit to branch master
in repository pytest.

commit 67133214465533c29639c0c0aad1a4d8a7b4dab6
Author: Sebastian Ramacher <sramacher at debian.org>
Date:   Fri Dec 9 17:48:26 2016 +0100

    Import pytest_3.0.5.orig.tar.gz
---
 AUTHORS                             |   4 ++
 CHANGELOG.rst                       |  72 ++++++++++++++++++-
 CONTRIBUTING.rst                    |  21 ++++--
 MANIFEST.in                         |  16 +++--
 PKG-INFO                            |  21 +++---
 README.rst                          |  18 ++---
 _pytest/__init__.py                 |   2 +-
 _pytest/_argcomplete.py             |   1 +
 _pytest/_code/code.py               |   2 +
 _pytest/_code/source.py             |  12 +---
 _pytest/assertion/__init__.py       |   4 +-
 _pytest/assertion/rewrite.py        |  17 +++--
 _pytest/capture.py                  |   1 +
 _pytest/config.py                   |  36 +++++++++-
 _pytest/debugging.py                |   2 +
 _pytest/fixtures.py                 |   2 +
 _pytest/helpconfig.py               |   4 +-
 _pytest/junitxml.py                 |   4 ++
 _pytest/main.py                     |  43 ++++++-----
 _pytest/mark.py                     |   2 +
 _pytest/pastebin.py                 |   6 ++
 _pytest/pytester.py                 |   9 +++
 _pytest/python.py                   |  16 ++---
 _pytest/runner.py                   |   7 ++
 _pytest/setuponly.py                |   4 +-
 _pytest/skipping.py                 |   4 ++
 _pytest/tmpdir.py                   |   1 +
 _pytest/unittest.py                 |   2 +
 doc/en/announce/index.rst           |   1 +
 doc/en/announce/release-3.0.5.rst   |  27 +++++++
 doc/en/assert.rst                   |   4 +-
 doc/en/cache.rst                    |   6 +-
 doc/en/capture.rst                  |   2 +-
 doc/en/doctest.rst                  |   2 +-
 doc/en/example/markers.rst          |  28 ++++----
 doc/en/example/nonpython.rst        |   6 +-
 doc/en/example/parametrize.rst      |  12 ++--
 doc/en/example/pythoncollection.rst |   6 +-
 doc/en/example/reportingdemo.rst    |   4 +-
 doc/en/example/simple.rst           |  22 +++---
 doc/en/fixture.rst                  |  13 ++--
 doc/en/getting-started.rst          |   4 +-
 doc/en/goodpractices.rst            |  12 ++--
 doc/en/index.rst                    |  10 +--
 doc/en/parametrize.rst              |   4 +-
 doc/en/recwarn.rst                  |   8 +++
 doc/en/skipping.rst                 |   2 +-
 doc/en/talks.rst                    |   3 +
 doc/en/tmpdir.rst                   |   2 +-
 doc/en/unittest.rst                 |   2 +-
 plugin-test.sh                      |  20 ------
 pytest.egg-info/PKG-INFO            |  21 +++---
 pytest.egg-info/SOURCES.txt         |   7 +-
 requirements-docs.txt               |   3 -
 runtox.py                           |   8 ---
 scripts/call-tox.bat                |   8 +++
 scripts/check-manifest.py           |  21 ++++++
 scripts/install-pypy.bat            |   6 ++
 setup.py                            |   1 +
 testing/code/test_code.py           |   5 ++
 testing/code/test_excinfo.py        |  25 ++++++-
 testing/python/approx.py            |  40 +++++++++--
 testing/python/collect.py           |   6 ++
 testing/python/fixture.py           |  10 +++
 testing/python/integration.py       |  10 +++
 testing/python/metafunc.py          |  12 ++++
 testing/test_assertion.py           |   3 +
 testing/test_assertrewrite.py       | 138 ++++++++++++++++++++++++++++++++++++
 testing/test_collection.py          |   5 ++
 testing/test_config.py              |  44 +++++++++++-
 testing/test_conftest.py            |  27 +++++++
 testing/test_junitxml.py            |  16 +++++
 testing/test_mark.py                |  21 +++++-
 testing/test_nose.py                |   4 ++
 testing/test_parseopt.py            |   5 +-
 testing/test_pastebin.py            |   2 +
 testing/test_pdb.py                 |   2 +
 testing/test_pluginmanager.py       |  26 ++++++-
 testing/test_pytester.py            |   4 ++
 testing/test_runner.py              |  10 +++
 tox.ini                             |  18 +++--
 81 files changed, 820 insertions(+), 221 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 6de0a11..8c7cb19 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -44,6 +44,7 @@ David Mohr
 David Vierra
 Diego Russo
 Dmitry Dygalo
+Duncan Betts
 Edison Gustavo Muenz
 Edoardo Batini
 Eduardo Schettino
@@ -82,6 +83,7 @@ Kevin Cox
 Lee Kamentsky
 Lev Maximov
 Lukas Bednar
+Luke Murphy
 Maciek Fijalkowski
 Maho
 Marc Schlaich
@@ -101,6 +103,8 @@ Michael Birtwell
 Michael Droettboom
 Michael Seifert
 Mike Lundy
+Ned Batchelder
+Neven Mundar
 Nicolas Delaby
 Oleg Pidsadnyi
 Oliver Bestwalter
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 178e540..cfcb012 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,3 +1,71 @@
+3.0.5
+=====
+
+* Add warning when not passing ``option=value`` correctly to ``-o/--override-ini`` (`#2105`_).
+  Also improved the help documentation. Thanks to `@mbukatov`_ for the report and
+  `@lwm`_ for the PR.
+
+* Now ``--confcutdir`` and ``--junit-xml`` are properly validated if they are directories
+  and filenames, respectively (`#2089`_ and `#2078`_). Thanks to `@lwm`_ for the PR.
+
+* Add hint to error message hinting possible missing ``__init__.py`` (`#478`_). Thanks `@DuncanBetts`_.
+
+* More accurately describe when fixture finalization occurs in documentation (`#687`_). Thanks `@DuncanBetts`_.
+
+* Provide ``:ref:`` targets for ``recwarn.rst`` so we can use intersphinx referencing.
+  Thanks to `@dupuy`_ for the report and `@lwm`_ for the PR.
+
+* In Python 2, use a simple ``+-`` ASCII string in the string representation of ``pytest.approx`` (for example ``"4 +- 4.0e-06"``)
+  because it is brittle to handle that in different contexts and representations internally in pytest
+  which can result in bugs such as `#2111`_. In Python 3, the representation still uses ``±`` (for example ``4 ± 4.0e-06``).
+  Thanks `@kerrick-lyft`_ for the report and `@nicoddemus`_ for the PR.
+
+* Using ``item.Function``, ``item.Module``, etc., is now issuing deprecation warnings, prefer
+  ``pytest.Function``, ``pytest.Module``, etc., instead (`#2034`_).
+  Thanks `@nmundar`_ for the PR.
+
+* Fix error message using ``approx`` with complex numbers (`#2082`_).
+  Thanks `@adler-j`_ for the report and `@nicoddemus`_ for the PR.
+
+* Fixed false-positives warnings from assertion rewrite hook for modules imported more than
+  once by the ``pytest_plugins`` mechanism.
+  Thanks `@nicoddemus`_ for the PR.
+
+* Remove an internal cache which could cause hooks from ``conftest.py`` files in
+  sub-directories to be called in other directories incorrectly (`#2016`_).
+  Thanks `@d-b-w`_ for the report and `@nicoddemus`_ for the PR.
+
+* Remove internal code meant to support earlier Python 3 versions that produced the side effect
+  of leaving ``None`` in ``sys.modules`` when expressions were evaluated by pytest (for example passing a condition
+  as a string to ``pytest.mark.skipif``)(`#2103`_).
+  Thanks `@jaraco`_ for the report and `@nicoddemus`_ for the PR.
+
+* Cope gracefully with a .pyc file with no matching .py file (`#2038`_). Thanks
+  `@nedbat`_.
+
+.. _ at adler-j: https://github.com/adler-j
+.. _ at d-b-w: https://bitbucket.org/d-b-w/
+.. _ at DuncanBetts: https://github.com/DuncanBetts
+.. _ at dupuy: https://bitbucket.org/dupuy/
+.. _ at kerrick-lyft: https://github.com/kerrick-lyft
+.. _ at lwm: https://github.com/lwm
+.. _ at mbukatov: https://github.com/mbukatov
+.. _ at nedbat: https://github.com/nedbat
+.. _ at nmundar: https://github.com/nmundar
+
+.. _#2016: https://github.com/pytest-dev/pytest/issues/2016
+.. _#2034: https://github.com/pytest-dev/pytest/issues/2034
+.. _#2038: https://github.com/pytest-dev/pytest/issues/2038
+.. _#2078: https://github.com/pytest-dev/pytest/issues/2078
+.. _#2082: https://github.com/pytest-dev/pytest/issues/2082
+.. _#2089: https://github.com/pytest-dev/pytest/issues/2089
+.. _#2103: https://github.com/pytest-dev/pytest/issues/2103
+.. _#2105: https://github.com/pytest-dev/pytest/issues/2105
+.. _#2111: https://github.com/pytest-dev/pytest/issues/2111
+.. _#478: https://github.com/pytest-dev/pytest/issues/478
+.. _#687: https://github.com/pytest-dev/pytest/issues/687
+
+
 3.0.4
 =====
 
@@ -22,10 +90,10 @@
   Thanks `@RonnyPfannschmidt`_ for the report and `@nicoddemus`_ for the PR.
 
 * Report teardown output on test failure (`#442`_).
-  Thanks `@matclab`_ or the PR.
+  Thanks `@matclab`_ for the PR.
 
 * Fix teardown error message in generated xUnit XML.
-  Thanks `@gdyuldin`_ or the PR.
+  Thanks `@gdyuldin`_ for the PR.
 
 * Properly handle exceptions in ``multiprocessing`` tasks (`#1984`_).
   Thanks `@adborden`_ for the report and `@nicoddemus`_ for the PR.
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 947d4e6..71dc04d 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -79,6 +79,16 @@ Pytest could always use more documentation.  What exactly is needed?
 You can also edit documentation files directly in the GitHub web interface,
 without using a local copy.  This can be convenient for small fixes.
 
+.. note::
+    Build the documentation locally with the following command:
+
+    .. code:: bash
+
+        $ tox -e docs
+
+    The built documentation should be available in the ``doc/en/_build/``.
+
+    Where 'en' refers to the documentation language.
 
 .. _submitplugin:
 
@@ -199,13 +209,10 @@ but here is a simple overview:
    You need to have Python 2.7 and 3.5 available in your system.  Now
    running tests is as simple as issuing this command::
 
-    $ python3 runtox.py -e linting,py27,py35
+    $ tox -e linting,py27,py35
 
    This command will run tests via the "tox" tool against Python 2.7 and 3.5
-   and also perform "lint" coding-style checks.  ``runtox.py`` is
-   a thin wrapper around ``tox`` which installs from a development package
-   index where newer (not yet released to PyPI) versions of dependencies
-   (especially ``py``) might be present.
+   and also perform "lint" coding-style checks.
 
 #. You can now edit your local working copy.
 
@@ -214,11 +221,11 @@ but here is a simple overview:
    To run tests on Python 2.7 and pass options to pytest (e.g. enter pdb on
    failure) to pytest you can do::
 
-    $ python3 runtox.py -e py27 -- --pdb
+    $ tox -e py27 -- --pdb
 
    Or to only run tests in a particular test module on Python 3.5::
 
-    $ python3 runtox.py -e py35 -- testing/test_config.py
+    $ tox -e py35 -- testing/test_config.py
 
 #. Commit and push once your tests pass and you are happy with your change(s)::
 
diff --git a/MANIFEST.in b/MANIFEST.in
index 079b225..c57cbd9 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -9,24 +9,28 @@ include HOWTORELEASE.rst
 include tox.ini
 include setup.py
 
-include .coveragerc
+recursive-include scripts *.py
+recursive-include scripts *.bat
 
-include plugin-test.sh
-include requirements-docs.txt
-include runtox.py
+include .coveragerc
 
 recursive-include bench *.py
 recursive-include extra *.py
 
 graft testing
 graft doc
+prune doc/en/_build
 
 exclude _pytest/impl
 
 graft _pytest/vendored_packages
 
 recursive-exclude * *.pyc *.pyo
+recursive-exclude testing/.hypothesis *
+recursive-exclude testing/freeze/~ *
+recursive-exclude testing/freeze/build *
+recursive-exclude testing/freeze/dist *
 
-exclude appveyor/install.ps1
 exclude appveyor.yml
-exclude appveyor
+exclude .travis.yml
+prune .github
diff --git a/PKG-INFO b/PKG-INFO
index a6bdd4a..3e7aeb0 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pytest
-Version: 3.0.4
+Version: 3.0.5
 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
@@ -32,31 +32,31 @@ Description: .. image:: http://docs.pytest.org/en/latest/_static/pytest1.png
         .. code-block:: python
         
             # content of test_sample.py
-            def func(x):
+            def inc(x):
                 return x + 1
         
             def test_answer():
-                assert func(3) == 5
+                assert inc(3) == 5
         
         
         To execute it::
         
             $ pytest
-            ======= test session starts ========
+            ============================= test session starts =============================    
             collected 1 items
         
             test_sample.py F
         
-            ======= FAILURES ========
-            _______ test_answer ________
+            ================================== FAILURES ===================================
+            _________________________________ test_answer _________________________________
         
                 def test_answer():
-            >       assert func(3) == 5
+            >       assert inc(3) == 5
             E       assert 4 == 5
-            E        +  where 4 = func(3)
+            E        +  where 4 = inc(3)
         
             test_sample.py:5: AssertionError
-            ======= 1 failed in 0.12 seconds ========
+            ========================== 1 failed in 0.04 seconds ===========================
         
         
         Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <http://docs.pytest.org/en/latest/getting-started.html#our-first-test-run>`_ for more examples.
@@ -97,7 +97,7 @@ Description: .. image:: http://docs.pytest.org/en/latest/_static/pytest1.png
         Changelog
         ---------
         
-        Consult the `Changelog <http://docs.pytest.org/en/latest/changelog.html>`_ page for fixes and enhancements of each version.
+        Consult the `Changelog <http://docs.pytest.org/en/latest/changelog.html>`__ page for fixes and enhancements of each version.
         
         
         License
@@ -109,6 +109,7 @@ Description: .. image:: http://docs.pytest.org/en/latest/_static/pytest1.png
         
         .. _`MIT`: https://github.com/pytest-dev/pytest/blob/master/LICENSE
         
+Keywords: test unittest
 Platform: unix
 Platform: linux
 Platform: osx
diff --git a/README.rst b/README.rst
index 6a5179e..d5650af 100644
--- a/README.rst
+++ b/README.rst
@@ -24,31 +24,31 @@ An example of a simple test:
 .. code-block:: python
 
     # content of test_sample.py
-    def func(x):
+    def inc(x):
         return x + 1
 
     def test_answer():
-        assert func(3) == 5
+        assert inc(3) == 5
 
 
 To execute it::
 
     $ pytest
-    ======= test session starts ========
+    ============================= test session starts =============================    
     collected 1 items
 
     test_sample.py F
 
-    ======= FAILURES ========
-    _______ test_answer ________
+    ================================== FAILURES ===================================
+    _________________________________ test_answer _________________________________
 
         def test_answer():
-    >       assert func(3) == 5
+    >       assert inc(3) == 5
     E       assert 4 == 5
-    E        +  where 4 = func(3)
+    E        +  where 4 = inc(3)
 
     test_sample.py:5: AssertionError
-    ======= 1 failed in 0.12 seconds ========
+    ========================== 1 failed in 0.04 seconds ===========================
 
 
 Due to ``pytest``'s detailed assertion introspection, only plain ``assert`` statements are used. See `getting-started <http://docs.pytest.org/en/latest/getting-started.html#our-first-test-run>`_ for more examples.
@@ -89,7 +89,7 @@ Please use the `GitHub issue tracker <https://github.com/pytest-dev/pytest/issue
 Changelog
 ---------
 
-Consult the `Changelog <http://docs.pytest.org/en/latest/changelog.html>`_ page for fixes and enhancements of each version.
+Consult the `Changelog <http://docs.pytest.org/en/latest/changelog.html>`__ page for fixes and enhancements of each version.
 
 
 License
diff --git a/_pytest/__init__.py b/_pytest/__init__.py
index 97cf252..be20d3d 100644
--- a/_pytest/__init__.py
+++ b/_pytest/__init__.py
@@ -1,2 +1,2 @@
 #
-__version__ = '3.0.4'
+__version__ = '3.0.5'
diff --git a/_pytest/_argcomplete.py b/_pytest/_argcomplete.py
index 955855a..3ab679d 100644
--- a/_pytest/_argcomplete.py
+++ b/_pytest/_argcomplete.py
@@ -87,6 +87,7 @@ class FastFilesCompleter:
             completion.append(x[prefix_dir:])
         return completion
 
+
 if os.environ.get('_ARGCOMPLETE'):
     try:
         import argcomplete.completers
diff --git a/_pytest/_code/code.py b/_pytest/_code/code.py
index 5b42379..616d5c4 100644
--- a/_pytest/_code/code.py
+++ b/_pytest/_code/code.py
@@ -343,6 +343,7 @@ class Traceback(list):
             l.append(entry.frame.f_locals)
         return None
 
+
 co_equal = compile('__recursioncache_locals_1 == __recursioncache_locals_2',
                    '?', 'eval')
 
@@ -846,6 +847,7 @@ def getrawcode(obj, trycall=True):
                     return x
         return obj
 
+
 if sys.version_info[:2] >= (3, 5):  # RecursionError introduced in 3.5
     def is_recursion_error(excinfo):
         return excinfo.errisinstance(RecursionError)  # noqa
diff --git a/_pytest/_code/source.py b/_pytest/_code/source.py
index 846e3cc..fcec0f5 100644
--- a/_pytest/_code/source.py
+++ b/_pytest/_code/source.py
@@ -4,7 +4,6 @@ from bisect import bisect_right
 import sys
 import inspect, tokenize
 import py
-from types import ModuleType
 cpy_compile = compile
 
 try:
@@ -192,14 +191,6 @@ class Source(object):
             if flag & _AST_FLAG:
                 return co
             lines = [(x + "\n") for x in self.lines]
-            if sys.version_info[0] >= 3:
-                # XXX py3's inspect.getsourcefile() checks for a module
-                # and a pep302 __loader__ ... we don't have a module
-                # at code compile-time so we need to fake it here
-                m = ModuleType("_pycodecompile_pseudo_module")
-                py.std.inspect.modulesbyfile[filename] = None
-                py.std.sys.modules[None] = m
-                m.__loader__ = 1
             py.std.linecache.cache[filename] = (1, None, lines, filename)
             return co
 
@@ -265,6 +256,7 @@ def findsource(obj):
     source.lines = [line.rstrip() for line in sourcelines]
     return source, lineno
 
+
 def getsource(obj, **kwargs):
     import _pytest._code
     obj = _pytest._code.getrawcode(obj)
@@ -275,6 +267,7 @@ def getsource(obj, **kwargs):
     assert isinstance(strsrc, str)
     return Source(strsrc, **kwargs)
 
+
 def deindent(lines, offset=None):
     if offset is None:
         for line in lines:
@@ -288,6 +281,7 @@ def deindent(lines, offset=None):
     if offset == 0:
         return list(lines)
     newlines = []
+
     def readline_generator(lines):
         for line in lines:
             yield line + '\n'
diff --git a/_pytest/assertion/__init__.py b/_pytest/assertion/__init__.py
index fd1ebe2..3f14a7a 100644
--- a/_pytest/assertion/__init__.py
+++ b/_pytest/assertion/__init__.py
@@ -29,7 +29,7 @@ def pytest_namespace():
 
 
 def register_assert_rewrite(*names):
-    """Register a module name to be rewritten on import.
+    """Register one or more module names to be rewritten on import.
 
     This function will make sure that this module or all modules inside
     the package will get their assert statements rewritten.
@@ -80,10 +80,12 @@ def install_importhook(config):
     config._assertstate.hook = hook = rewrite.AssertionRewritingHook(config)
     sys.meta_path.insert(0, hook)
     config._assertstate.trace('installed rewrite import hook')
+
     def undo():
         hook = config._assertstate.hook
         if hook is not None and hook in sys.meta_path:
             sys.meta_path.remove(hook)
+
     config.add_cleanup(undo)
     return hook
 
diff --git a/_pytest/assertion/rewrite.py b/_pytest/assertion/rewrite.py
index 6b4c1f4..abf5b49 100644
--- a/_pytest/assertion/rewrite.py
+++ b/_pytest/assertion/rewrite.py
@@ -80,7 +80,12 @@ class AssertionRewritingHook(object):
             tp = desc[2]
             if tp == imp.PY_COMPILED:
                 if hasattr(imp, "source_from_cache"):
-                    fn = imp.source_from_cache(fn)
+                    try:
+                        fn = imp.source_from_cache(fn)
+                    except ValueError:
+                        # Python 3 doesn't like orphaned but still-importable
+                        # .pyc files.
+                        fn = fn[:-1]
                 else:
                     fn = fn[:-1]
             elif tp != imp.PY_SOURCE:
@@ -181,16 +186,15 @@ class AssertionRewritingHook(object):
         """
         already_imported = set(names).intersection(set(sys.modules))
         if already_imported:
-            for name in names:
+            for name in already_imported:
                 if name not in self._rewritten_names:
-                    self._warn_already_imported(already_imported)
+                    self._warn_already_imported(name)
         self._must_rewrite.update(names)
 
-    def _warn_already_imported(self, names):
+    def _warn_already_imported(self, name):
         self.config.warn(
             'P1',
-            'Modules are already imported so can not be re-written: %s' %
-            ','.join(names))
+            'Module already imported so can not be re-written: %s' % name)
 
     def load_module(self, name):
         # If there is an existing module object named 'fullname' in
@@ -276,6 +280,7 @@ def _write_pyc(state, co, source_stat, pyc):
         fp.close()
     return True
 
+
 RN = "\r\n".encode("utf-8")
 N = "\n".encode("utf-8")
 
diff --git a/_pytest/capture.py b/_pytest/capture.py
index 9f60db6..eea81ca 100644
--- a/_pytest/capture.py
+++ b/_pytest/capture.py
@@ -152,6 +152,7 @@ class CaptureManager:
         item.add_report_section(when, "stdout", out)
         item.add_report_section(when, "stderr", err)
 
+
 error_capsysfderror = "cannot use capsys and capfd at the same time"
 
 
diff --git a/_pytest/config.py b/_pytest/config.py
index 5df198e..fe386ed 100644
--- a/_pytest/config.py
+++ b/_pytest/config.py
@@ -65,9 +65,33 @@ def main(args=None, plugins=None):
 class cmdline:  # compatibility namespace
     main = staticmethod(main)
 
+
 class UsageError(Exception):
     """ error in pytest usage or invocation"""
 
+
+def filename_arg(path, optname):
+    """ Argparse type validator for filename arguments.
+
+    :path: path of filename
+    :optname: name of the option
+    """
+    if os.path.isdir(path):
+        raise UsageError("{0} must be a filename, given: {1}".format(optname, path))
+    return path
+
+
+def directory_arg(path, optname):
+    """Argparse type validator for directory arguments.
+
+    :path: path of directory
+    :optname: name of the option
+    """
+    if not os.path.isdir(path):
+        raise UsageError("{0} must be a directory, given: {1}".format(optname, path))
+    return path
+
+
 _preinit = []
 
 default_plugins = (
@@ -594,7 +618,7 @@ class Argument:
                 if typ == 'choice':
                     warnings.warn(
                         'type argument to addoption() is a string %r.'
-                        ' For parsearg this is optional and when supplied '
+                        ' For parsearg this is optional and when supplied'
                         ' should be a type.'
                         ' (options: %s)' % (typ, names),
                         DeprecationWarning,
@@ -818,9 +842,11 @@ class Notset:
     def __repr__(self):
         return "<NOTSET>"
 
+
 notset = Notset()
 FILE_OR_DIR = 'file_or_dir'
 
+
 class Config(object):
     """ access to configuration values, pluginmanager and plugin hooks.  """
 
@@ -843,9 +869,11 @@ class Config(object):
         self._warn = self.pluginmanager._warn
         self.pluginmanager.register(self, "pytestconfig")
         self._configured = False
+
         def do_setns(dic):
             import pytest
             setns(pytest, dic)
+
         self.hook.pytest_namespace.call_historic(do_setns, {})
         self.hook.pytest_addoption.call_historic(kwargs=dict(parser=self._parser))
 
@@ -1001,6 +1029,7 @@ class Config(object):
         self.pluginmanager.load_setuptools_entrypoints(entrypoint_name)
         self.pluginmanager.consider_env()
         self.known_args_namespace = ns = self._parser.parse_known_args(args, namespace=self.option.copy())
+        confcutdir = self.known_args_namespace.confcutdir
         if self.known_args_namespace.confcutdir is None and self.inifile:
             confcutdir = py.path.local(self.inifile).dirname
             self.known_args_namespace.confcutdir = confcutdir
@@ -1120,7 +1149,10 @@ class Config(object):
         if self.getoption("override_ini", None):
             for ini_config_list in self.option.override_ini:
                 for ini_config in ini_config_list:
-                    (key, user_ini_value) = ini_config.split("=", 1)
+                    try:
+                        (key, user_ini_value) = ini_config.split("=", 1)
+                    except ValueError:
+                        raise UsageError("-o/--override-ini expects option=value style.")
                     if key == name:
                         value = user_ini_value
         return value
diff --git a/_pytest/debugging.py b/_pytest/debugging.py
index 299b050..d96170b 100644
--- a/_pytest/debugging.py
+++ b/_pytest/debugging.py
@@ -31,10 +31,12 @@ def pytest_configure(config):
         pytestPDB._pdb_cls = pdb_cls
 
     old = (pdb.set_trace, pytestPDB._pluginmanager)
+
     def fin():
         pdb.set_trace, pytestPDB._pluginmanager = old
         pytestPDB._config = None
         pytestPDB._pdb_cls = pdb.Pdb
+
     pdb.set_trace = pytest.set_trace
     pytestPDB._pluginmanager = config.pluginmanager
     pytestPDB._config = config
diff --git a/_pytest/fixtures.py b/_pytest/fixtures.py
index 3f08b7c..28bcd4d 100644
--- a/_pytest/fixtures.py
+++ b/_pytest/fixtures.py
@@ -32,11 +32,13 @@ scope2props["function"] = scope2props["instance"] + ("function", "keywords")
 def scopeproperty(name=None, doc=None):
     def decoratescope(func):
         scopename = name or func.__name__
+
         def provide(self):
             if func.__name__ in scope2props[self.scope]:
                 return func(self)
             raise AttributeError("%s not available in %s-scoped context" % (
                 scopename, self.scope))
+
         return property(provide, None, None, func.__doc__)
     return decoratescope
 
diff --git a/_pytest/helpconfig.py b/_pytest/helpconfig.py
index 538a763..6e66b11 100644
--- a/_pytest/helpconfig.py
+++ b/_pytest/helpconfig.py
@@ -23,7 +23,7 @@ def pytest_addoption(parser):
     group._addoption(
         '-o', '--override-ini', nargs='*', dest="override_ini",
         action="append",
-        help="override config option, e.g. `-o xfail_strict=True`.")
+        help="override config option with option=value style, e.g. `-o xfail_strict=True`.")
 
 
 @pytest.hookimpl(hookwrapper=True)
@@ -41,12 +41,14 @@ def pytest_cmdline_parse():
         config.trace.root.setwriter(debugfile.write)
         undo_tracing = config.pluginmanager.enable_tracing()
         sys.stderr.write("writing pytestdebug information to %s\n" % path)
+
         def unset_tracing():
             debugfile.close()
             sys.stderr.write("wrote pytestdebug information to %s\n" %
                              debugfile.name)
             config.trace.root.setwriter(None)
             undo_tracing()
+
         config.add_cleanup(unset_tracing)
 
 def pytest_cmdline_main(config):
diff --git a/_pytest/junitxml.py b/_pytest/junitxml.py
index 97d0675..317382e 100644
--- a/_pytest/junitxml.py
+++ b/_pytest/junitxml.py
@@ -8,12 +8,14 @@ Based on initial code from Ross Lawley.
 # Output conforms to https://github.com/jenkinsci/xunit-plugin/blob/master/
 # src/main/resources/org/jenkinsci/plugins/xunit/types/model/xsd/junit-10.xsd
 
+import functools
 import py
 import os
 import re
 import sys
 import time
 import pytest
+from _pytest.config import filename_arg
 
 # Python 2.X and 3.X compatibility
 if sys.version_info[0] < 3:
@@ -27,6 +29,7 @@ else:
 class Junit(py.xml.Namespace):
     pass
 
+
 # We need to get the subset of the invalid unicode ranges according to
 # XML 1.0 which are valid in this python build.  Hence we calculate
 # this dynamically instead of hardcoding it.  The spec range of valid
@@ -213,6 +216,7 @@ def pytest_addoption(parser):
         action="store",
         dest="xmlpath",
         metavar="path",
+        type=functools.partial(filename_arg, optname="--junitxml"),
         default=None,
         help="create junit-xml style report file at given path.")
     group.addoption(
diff --git a/_pytest/main.py b/_pytest/main.py
index 5771a16..52876c1 100644
--- a/_pytest/main.py
+++ b/_pytest/main.py
@@ -1,4 +1,5 @@
 """ core implementation of testing process: init, session, runtest loop. """
+import functools
 import os
 import sys
 
@@ -11,6 +12,7 @@ try:
 except ImportError:
     from UserDict import DictMixin as MappingMixin
 
+from _pytest.config import directory_arg
 from _pytest.runner import collect_one_node
 
 tracebackcutdir = py.path.local(_pytest.__file__).dirpath()
@@ -58,7 +60,7 @@ def pytest_addoption(parser):
     # when changing this to --conf-cut-dir, config.py Conftest.setinitial
     # needs upgrading as well
     group.addoption('--confcutdir', dest="confcutdir", default=None,
-        metavar="dir",
+        metavar="dir", type=functools.partial(directory_arg, optname="--confcutdir"),
         help="only load conftest.py's relative to specified dir.")
     group.addoption('--noconftest', action="store_true",
         dest="noconftest", default=False,
@@ -190,7 +192,9 @@ class FSHookProxy:
 
 def compatproperty(name):
     def fget(self):
-        # deprecated - use pytest.name
+        import warnings
+        warnings.warn("This usage is deprecated, please use pytest.{0} instead".format(name),
+                      PendingDeprecationWarning, stacklevel=2)
         return getattr(pytest, name)
 
     return property(fget)
@@ -535,7 +539,6 @@ class Session(FSCollector):
     def __init__(self, config):
         FSCollector.__init__(self, config.rootdir, parent=None,
                              config=config, session=self)
-        self._fs2hookproxy = {}
         self.testsfailed = 0
         self.testscollected = 0
         self.shouldstop = False
@@ -566,23 +569,18 @@ class Session(FSCollector):
         return path in self._initialpaths
 
     def gethookproxy(self, fspath):
-        try:
-            return self._fs2hookproxy[fspath]
-        except KeyError:
-            # check if we have the common case of running
-            # hooks with all conftest.py filesall conftest.py
-            pm = self.config.pluginmanager
-            my_conftestmodules = pm._getconftestmodules(fspath)
-            remove_mods = pm._conftest_plugins.difference(my_conftestmodules)
-            if remove_mods:
-                # one or more conftests are not in use at this fspath
-                proxy = FSHookProxy(fspath, pm, remove_mods)
-            else:
-                # all plugis are active for this fspath
-                proxy = self.config.hook
-
-            self._fs2hookproxy[fspath] = proxy
-            return proxy
+        # check if we have the common case of running
+        # hooks with all conftest.py filesall conftest.py
+        pm = self.config.pluginmanager
+        my_conftestmodules = pm._getconftestmodules(fspath)
+        remove_mods = pm._conftest_plugins.difference(my_conftestmodules)
+        if remove_mods:
+            # one or more conftests are not in use at this fspath
+            proxy = FSHookProxy(fspath, pm, remove_mods)
+        else:
+            # all plugis are active for this fspath
+            proxy = self.config.hook
+        return proxy
 
     def perform_collect(self, args=None, genitems=True):
         hook = self.config.hook
@@ -704,10 +702,9 @@ class Session(FSCollector):
         path = self.config.invocation_dir.join(relpath, abs=True)
         if not path.check():
             if self.config.option.pyargs:
-                msg = "file or package not found: "
+                raise pytest.UsageError("file or package not found: " + arg + " (missing __init__.py?)")
             else:
-                msg = "file not found: "
-            raise pytest.UsageError(msg + arg)
+                raise pytest.UsageError("file not found: " + arg)
         parts[0] = path
         return parts
 
diff --git a/_pytest/mark.py b/_pytest/mark.py
index 640c4e6..357a604 100644
--- a/_pytest/mark.py
+++ b/_pytest/mark.py
@@ -54,6 +54,8 @@ def pytest_cmdline_main(config):
             tw.line()
         config._ensure_unconfigure()
         return 0
+
+
 pytest_cmdline_main.tryfirst = True
 
 
diff --git a/_pytest/pastebin.py b/_pytest/pastebin.py
index 4ec62d0..9f1cf90 100644
--- a/_pytest/pastebin.py
+++ b/_pytest/pastebin.py
@@ -11,6 +11,7 @@ def pytest_addoption(parser):
         choices=['failed', 'all'],
         help="send failed|all info to bpaste.net pastebin service.")
 
+
 @pytest.hookimpl(trylast=True)
 def pytest_configure(config):
     import py
@@ -23,13 +24,16 @@ def pytest_configure(config):
             # pastebin file will be utf-8 encoded binary file
             config._pastebinfile = tempfile.TemporaryFile('w+b')
             oldwrite = tr._tw.write
+
             def tee_write(s, **kwargs):
                 oldwrite(s, **kwargs)
                 if py.builtin._istext(s):
                     s = s.encode('utf-8')
                 config._pastebinfile.write(s)
+
             tr._tw.write = tee_write
 
+
 def pytest_unconfigure(config):
     if hasattr(config, '_pastebinfile'):
         # get terminal contents and delete file
@@ -45,6 +49,7 @@ def pytest_unconfigure(config):
         pastebinurl = create_new_paste(sessionlog)
         tr.write_line("pastebin session-log: %s\n" % pastebinurl)
 
+
 def create_new_paste(contents):
     """
     Creates a new paste using bpaste.net service.
@@ -72,6 +77,7 @@ def create_new_paste(contents):
     else:
         return 'bad response: ' + response
 
+
 def pytest_terminal_summary(terminalreporter):
     import _pytest.config
     if terminalreporter.config.option.pastebin != "failed":
diff --git a/_pytest/pytester.py b/_pytest/pytester.py
index a8bb397..17ff529 100644
--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -478,11 +478,14 @@ class Testdir:
         ret = None
         for name, value in items:
             p = self.tmpdir.join(name).new(ext=ext)
+            p.dirpath().ensure_dir()
             source = Source(value)
+
             def my_totext(s, encoding="utf-8"):
                 if py.builtin._isbytes(s):
                     s = py.builtin._totext(s, encoding=encoding)
                 return s
+
             source_unicode = "\n".join([my_totext(line) for line in source.lines])
             source = py.builtin._totext(source_unicode)
             content = source.strip().encode("utf-8") # + "\n"
@@ -692,12 +695,15 @@ class Testdir:
         # warning which will trigger to say they can no longer be
         # re-written, which is fine as they are already re-written.
         orig_warn = AssertionRewritingHook._warn_already_imported
+
         def revert():
             AssertionRewritingHook._warn_already_imported = orig_warn
+
         self.request.addfinalizer(revert)
         AssertionRewritingHook._warn_already_imported = lambda *a: None
 
         rec = []
+
         class Collect:
             def pytest_configure(x, config):
                 rec.append(self.make_hook_recorder(config.pluginmanager))
@@ -732,10 +738,13 @@ class Testdir:
             try:
                 reprec = self.inline_run(*args, **kwargs)
             except SystemExit as e:
+
                 class reprec:
                     ret = e.args[0]
+
             except Exception:
                 traceback.print_exc()
+
                 class reprec:
                     ret = 3
         finally:
diff --git a/_pytest/python.py b/_pytest/python.py
index 18432c1..e46f2f1 100644
--- a/_pytest/python.py
+++ b/_pytest/python.py
@@ -214,9 +214,12 @@ class PyobjMixin(PyobjContext):
             if obj is None:
                 self._obj = obj = self._getobj()
             return obj
+
         def fset(self, value):
             self._obj = value
+
         return property(fget, fset, None, "underlying python object")
+
... 2647 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