From 9275012ef789048998d1b87b9536bd7c2c063596 Mon Sep 17 00:00:00 2001
From: Daniil Galiev <liinda@yandex-team.ru>
Date: Mon, 9 Sep 2019 00:27:55 +0500
Subject: [PATCH 01/14] fix bug with nonskipped first test in package

---
 AUTHORS                   |  1 +
 changelog/5830.bugfix.rst |  1 +
 src/_pytest/python.py     | 16 ++++++++++------
 testing/test_skipping.py  | 23 +++++++++++++++++++++++
 4 files changed, 35 insertions(+), 6 deletions(-)
 create mode 100644 changelog/5830.bugfix.rst

diff --git a/AUTHORS b/AUTHORS
index e11400c1f..d0e584f63 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -70,6 +70,7 @@ Daniel Hahler
 Daniel Nuri
 Daniel Wandschneider
 Danielle Jenkins
+Daniil Galiev
 Dave Hunt
 David Díaz-Barquero
 David Mohr
diff --git a/changelog/5830.bugfix.rst b/changelog/5830.bugfix.rst
new file mode 100644
index 000000000..355790fd4
--- /dev/null
+++ b/changelog/5830.bugfix.rst
@@ -0,0 +1 @@
+Fix fail skipping the first test in package marked as ``skip``
diff --git a/src/_pytest/python.py b/src/_pytest/python.py
index 913a93bc0..97a3ac805 100644
--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -251,18 +251,21 @@ class PyobjMixin(PyobjContext):
     @property
     def obj(self):
         """Underlying Python object."""
+        self._mount_obj_if_needed()
+        return self._obj
+
+    @obj.setter
+    def obj(self, value):
+        self._obj = value
+
+    def _mount_obj_if_needed(self):
         obj = getattr(self, "_obj", None)
         if obj is None:
             self._obj = obj = self._getobj()
             # XXX evil hack
             # used to avoid Instance collector marker duplication
             if self._ALLOW_MARKERS:
-                self.own_markers.extend(get_unpacked_marks(self.obj))
-        return obj
-
-    @obj.setter
-    def obj(self, value):
-        self._obj = value
+                self.own_markers.extend(get_unpacked_marks(obj))
 
     def _getobj(self):
         """Gets the underlying Python object. May be overwritten by subclasses."""
@@ -628,6 +631,7 @@ class Package(Module):
         return path in self.session._initialpaths
 
     def collect(self):
+        self._mount_obj_if_needed()
         this_path = self.fspath.dirpath()
         init_module = this_path.join("__init__.py")
         if init_module.check(file=1) and path_matches_patterns(
diff --git a/testing/test_skipping.py b/testing/test_skipping.py
index 8bba479f1..371c3a4db 100644
--- a/testing/test_skipping.py
+++ b/testing/test_skipping.py
@@ -1162,3 +1162,26 @@ def test_importorskip():
         match="^could not import 'doesnotexist': No module named .*",
     ):
         pytest.importorskip("doesnotexist")
+
+
+def test_skip_package(testdir):
+    testdir.makepyfile(
+        __init__="""
+        import pytest
+        pytestmark = pytest.mark.skip
+    """
+    )
+
+    testdir.makepyfile(
+        """
+        import pytest
+        def test_skip1():
+            assert 0
+        def test_skip2():
+            assert 0
+    """
+    )
+
+    result = testdir.inline_run()
+    _, skipped, _ = result.listoutcomes()
+    assert len(skipped) == 2

From b94eb4cb7b455282144e99e9c0b21aa80596e993 Mon Sep 17 00:00:00 2001
From: Daniil Galiev <liinda@yandex-team.ru>
Date: Thu, 12 Sep 2019 01:57:04 +0500
Subject: [PATCH 02/14] disable _ALLOW_MARKERS in module __init__.py

---
 src/_pytest/python.py | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/_pytest/python.py b/src/_pytest/python.py
index 97a3ac805..a1f6d5067 100644
--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -548,6 +548,15 @@ class Module(nodes.File, PyCollector):
         return mod
 
 
+class InitModule(Module):
+    _ALLOW_MARKERS = False
+
+    def __repr__(self):
+        if type(self) == InitModule:
+            return "<{} {}>".format(Module.__name__, getattr(self, "name", None))
+        return super().__repr__()
+
+
 class Package(Module):
     def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
         session = parent.session
@@ -637,7 +646,7 @@ class Package(Module):
         if init_module.check(file=1) and path_matches_patterns(
             init_module, self.config.getini("python_files")
         ):
-            yield Module(init_module, self)
+            yield InitModule(init_module, self)
         pkg_prefixes = set()
         for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
             # We will visit our own __init__.py file, in which case we skip it.

From 5cefcb20522e3d48282ba3f889162be5ef8e9040 Mon Sep 17 00:00:00 2001
From: Daniil Galiev <liinda@yandex-team.ru>
Date: Sat, 28 Sep 2019 00:06:46 +0500
Subject: [PATCH 03/14] refactor disabling markers

---
 src/_pytest/python.py | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/_pytest/python.py b/src/_pytest/python.py
index a1f6d5067..45a4e66a9 100644
--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -432,6 +432,14 @@ class PyCollector(PyobjMixin, nodes.Collector):
 class Module(nodes.File, PyCollector):
     """ Collector for test classes and functions. """
 
+    def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
+        if fspath.basename == "__init__.py":
+            self._ALLOW_MARKERS = False
+
+        nodes.FSCollector.__init__(
+            self, fspath, parent=parent, config=config, session=session, nodeid=nodeid
+        )
+
     def _getobj(self):
         return self._importtestmodule()
 
@@ -548,15 +556,6 @@ class Module(nodes.File, PyCollector):
         return mod
 
 
-class InitModule(Module):
-    _ALLOW_MARKERS = False
-
-    def __repr__(self):
-        if type(self) == InitModule:
-            return "<{} {}>".format(Module.__name__, getattr(self, "name", None))
-        return super().__repr__()
-
-
 class Package(Module):
     def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
         session = parent.session
@@ -646,7 +645,7 @@ class Package(Module):
         if init_module.check(file=1) and path_matches_patterns(
             init_module, self.config.getini("python_files")
         ):
-            yield InitModule(init_module, self)
+            yield Module(init_module, self)
         pkg_prefixes = set()
         for path in this_path.visit(rec=self._recurse, bf=True, sort=True):
             # We will visit our own __init__.py file, in which case we skip it.

From 41604eeb3e70c35103b5260b20419a817a0fe6ac Mon Sep 17 00:00:00 2001
From: Daniel Hahler <git@thequod.de>
Date: Fri, 8 Nov 2019 22:38:50 +0100
Subject: [PATCH 04/14] setup.cfg: fix check-manifest ignore  [ci skip]

---
 setup.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.cfg b/setup.cfg
index 60e866562..0c0cb4861 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -57,7 +57,7 @@ upload-dir = doc/en/build/html
 
 [check-manifest]
 ignore =
-  _pytest/_version.py
+  src/_pytest/_version.py
 
 [devpi:upload]
 formats = sdist.tgz,bdist_wheel

From 0b40749c9826d67ff44044608778d6ccd763e95a Mon Sep 17 00:00:00 2001
From: Brett Cannon <54418+brettcannon@users.noreply.github.com>
Date: Tue, 12 Nov 2019 12:32:05 -0800
Subject: [PATCH 05/14] Delineate syntactically that the 'match' argument to
 'raises' is keyword-only

---
 doc/en/reference.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doc/en/reference.rst b/doc/en/reference.rst
index 9c3a4c731..4391cfcb1 100644
--- a/doc/en/reference.rst
+++ b/doc/en/reference.rst
@@ -59,7 +59,7 @@ pytest.raises
 
 **Tutorial**: :ref:`assertraises`.
 
-.. autofunction:: pytest.raises(expected_exception: Exception, [match])
+.. autofunction:: pytest.raises(expected_exception: Exception [, *, match])
     :with: excinfo
 
 pytest.deprecated_call

From 6f2c0fd2e8e8154c8129900c9a1c650068811404 Mon Sep 17 00:00:00 2001
From: Bruno Oliveira <nicoddemus@gmail.com>
Date: Wed, 13 Nov 2019 17:51:14 -0300
Subject: [PATCH 06/14] Show a better message when 'request' is used in
 parametrize

Fix #6183
---
 changelog/6183.bugfix.rst  |  2 ++
 src/_pytest/python.py      |  6 ++++++
 testing/python/metafunc.py | 13 +++++++++++++
 3 files changed, 21 insertions(+)
 create mode 100644 changelog/6183.bugfix.rst

diff --git a/changelog/6183.bugfix.rst b/changelog/6183.bugfix.rst
new file mode 100644
index 000000000..5c4d66e24
--- /dev/null
+++ b/changelog/6183.bugfix.rst
@@ -0,0 +1,2 @@
+Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more
+user-friendly error.
diff --git a/src/_pytest/python.py b/src/_pytest/python.py
index d16407bdd..306e5f217 100644
--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -977,6 +977,12 @@ class Metafunc(fixtures.FuncargnamesCompatAttr):
         )
         del argvalues
 
+        if "request" in argnames:
+            fail(
+                "'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
+                pytrace=False,
+            )
+
         if scope is None:
             scope = _find_parametrized_scope(argnames, self._arg2fixturedefs, indirect)
 
diff --git a/testing/python/metafunc.py b/testing/python/metafunc.py
index 5becb0f8c..860b21ff2 100644
--- a/testing/python/metafunc.py
+++ b/testing/python/metafunc.py
@@ -72,6 +72,19 @@ class TestMetafunc:
         ):
             metafunc.parametrize("x", [1], scope="doggy")
 
+    def test_parametrize_request_name(self, testdir):
+        """Show proper error  when 'request' is used as a parameter name in parametrize (#6183)"""
+
+        def func(request):
+            raise NotImplementedError()
+
+        metafunc = self.Metafunc(func)
+        with pytest.raises(
+            pytest.fail.Exception,
+            match=r"'request' is a reserved name and cannot be used in @pytest.mark.parametrize",
+        ):
+            metafunc.parametrize("request", [1])
+
     def test_find_parametrized_scope(self):
         """unittest for _find_parametrized_scope (#3941)"""
         from _pytest.python import _find_parametrized_scope

From 350c27c8b441ea73a3c5bf45500659da364f090c Mon Sep 17 00:00:00 2001
From: Hugo <hugovk@users.noreply.github.com>
Date: Thu, 14 Nov 2019 11:36:47 +0200
Subject: [PATCH 07/14] Update text in PR template

---
 .github/PULL_REQUEST_TEMPLATE.md | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index f516959bc..843b67294 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -2,7 +2,6 @@
 Thanks for submitting a PR, your contribution is really appreciated!
 
 Here is a quick checklist that should be present in PRs.
-(please delete this text from the final description, this is just a guideline)
 -->
 
 - [ ] Target the `master` branch for bug fixes, documentation updates and trivial changes.
@@ -10,7 +9,7 @@ Here is a quick checklist that should be present in PRs.
 - [ ] Include documentation when adding new features.
 - [ ] Include new tests or update existing tests when applicable.
 
-Unless your change is trivial or a small documentation fix (e.g.,  a typo or reword of a small section) please:
+Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
 
 - [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/master/changelog/README.rst) for details.
-- [ ] Add yourself to `AUTHORS` in alphabetical order;
+- [ ] Add yourself to `AUTHORS` in alphabetical order.

From 48ec7d28c6485da6dc220cd9a5acdbcfc6615ff1 Mon Sep 17 00:00:00 2001
From: Hugo <hugovk@users.noreply.github.com>
Date: Thu, 14 Nov 2019 12:01:40 +0200
Subject: [PATCH 08/14] Make whole checklist a comment to avoid incomplete
 TODOs in PRs

---
 .github/PULL_REQUEST_TEMPLATE.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 843b67294..7436f7146 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -2,7 +2,6 @@
 Thanks for submitting a PR, your contribution is really appreciated!
 
 Here is a quick checklist that should be present in PRs.
--->
 
 - [ ] Target the `master` branch for bug fixes, documentation updates and trivial changes.
 - [ ] Target the `features` branch for new features, improvements, and removals/deprecations.
@@ -13,3 +12,4 @@ Unless your change is trivial or a small documentation fix (e.g., a typo or rewo
 
 - [ ] Create a new changelog file in the `changelog` folder, with a name like `<ISSUE NUMBER>.<TYPE>.rst`. See [changelog/README.rst](https://github.com/pytest-dev/pytest/blob/master/changelog/README.rst) for details.
 - [ ] Add yourself to `AUTHORS` in alphabetical order.
+-->

From 5e8c47faad91ccf49897a290efd62bcac1971ff7 Mon Sep 17 00:00:00 2001
From: Bruno Oliveira <bruno@esss.co>
Date: Thu, 14 Nov 2019 11:12:06 -0300
Subject: [PATCH 09/14] Preparing release version 5.2.3

---
 CHANGELOG.rst                     | 16 ++++++++++++++++
 changelog/5830.bugfix.rst         |  1 -
 changelog/6099.bugfix.rst         |  1 -
 changelog/6183.bugfix.rst         |  2 --
 doc/en/announce/index.rst         |  1 +
 doc/en/announce/release-5.2.3.rst | 28 ++++++++++++++++++++++++++++
 doc/en/example/parametrize.rst    |  4 ++--
 doc/en/example/reportingdemo.rst  |  4 ++--
 doc/en/getting-started.rst        |  2 +-
 9 files changed, 50 insertions(+), 9 deletions(-)
 delete mode 100644 changelog/5830.bugfix.rst
 delete mode 100644 changelog/6099.bugfix.rst
 delete mode 100644 changelog/6183.bugfix.rst
 create mode 100644 doc/en/announce/release-5.2.3.rst

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 375b5dabf..402a35d73 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -18,6 +18,22 @@ with advance notice in the **Deprecations** section of releases.
 
 .. towncrier release notes start
 
+pytest 5.2.3 (2019-11-14)
+=========================
+
+Bug Fixes
+---------
+
+- `#5830 <https://github.com/pytest-dev/pytest/issues/5830>`_: Fix fail skipping the first test in package marked as ``skip``
+
+
+- `#6099 <https://github.com/pytest-dev/pytest/issues/6099>`_: Fix ``--trace`` when used with parametrized functions.
+
+
+- `#6183 <https://github.com/pytest-dev/pytest/issues/6183>`_: Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more
+  user-friendly error.
+
+
 pytest 5.2.2 (2019-10-24)
 =========================
 
diff --git a/changelog/5830.bugfix.rst b/changelog/5830.bugfix.rst
deleted file mode 100644
index 355790fd4..000000000
--- a/changelog/5830.bugfix.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix fail skipping the first test in package marked as ``skip``
diff --git a/changelog/6099.bugfix.rst b/changelog/6099.bugfix.rst
deleted file mode 100644
index 77f33cde1..000000000
--- a/changelog/6099.bugfix.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix ``--trace`` when used with parametrized functions.
diff --git a/changelog/6183.bugfix.rst b/changelog/6183.bugfix.rst
deleted file mode 100644
index 5c4d66e24..000000000
--- a/changelog/6183.bugfix.rst
+++ /dev/null
@@ -1,2 +0,0 @@
-Using ``request`` as a parameter name in ``@pytest.mark.parametrize`` now produces a more
-user-friendly error.
diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst
index f7a634b31..05530dd2e 100644
--- a/doc/en/announce/index.rst
+++ b/doc/en/announce/index.rst
@@ -6,6 +6,7 @@ Release announcements
    :maxdepth: 2
 
 
+   release-5.2.3
    release-5.2.2
    release-5.2.1
    release-5.2.0
diff --git a/doc/en/announce/release-5.2.3.rst b/doc/en/announce/release-5.2.3.rst
new file mode 100644
index 000000000..bfb62a1b8
--- /dev/null
+++ b/doc/en/announce/release-5.2.3.rst
@@ -0,0 +1,28 @@
+pytest-5.2.3
+=======================================
+
+pytest 5.2.3 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
+
+Thanks to all who contributed to this release, among them:
+
+* Anthony Sottile
+* Brett Cannon
+* Bruno Oliveira
+* Daniel Hahler
+* Daniil Galiev
+* David Szotten
+* Florian Bruhin
+* Patrick Harmon
+* Ran Benita
+* Zac Hatfield-Dodds
+* Zak Hassan
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst
index 1220cfb4d..48ab95fda 100644
--- a/doc/en/example/parametrize.rst
+++ b/doc/en/example/parametrize.rst
@@ -475,10 +475,10 @@ Running it results in some skips if we don't have all the python interpreters in
 .. code-block:: pytest
 
    . $ pytest -rs -q multipython.py
-   ssssssssssssssssssssssss...                                          [100%]
+   ssssssssssss...ssssssssssss                                          [100%]
    ========================= short test summary info ==========================
    SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
-   SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.6' not found
+   SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.7' not found
    3 passed, 24 skipped in 0.12s
 
 Indirect parametrization of optional implementations/imports
diff --git a/doc/en/example/reportingdemo.rst b/doc/en/example/reportingdemo.rst
index eb978c5ea..1c06782f6 100644
--- a/doc/en/example/reportingdemo.rst
+++ b/doc/en/example/reportingdemo.rst
@@ -436,7 +436,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
             items = [1, 2, 3]
             print("items is {!r}".format(items))
     >       a, b = items.pop()
-    E       TypeError: cannot unpack non-iterable int object
+    E       TypeError: 'int' object is not iterable
 
     failure_demo.py:181: TypeError
     --------------------------- Captured stdout call ---------------------------
@@ -516,7 +516,7 @@ Here is a nice run of several failures and how ``pytest`` presents things:
         def test_z2_type_error(self):
             items = 3
     >       a, b = items
-    E       TypeError: cannot unpack non-iterable int object
+    E       TypeError: 'int' object is not iterable
 
     failure_demo.py:222: TypeError
     ______________________ TestMoreErrors.test_startswith ______________________
diff --git a/doc/en/getting-started.rst b/doc/en/getting-started.rst
index 97347f126..2bdd68ea3 100644
--- a/doc/en/getting-started.rst
+++ b/doc/en/getting-started.rst
@@ -28,7 +28,7 @@ Install ``pytest``
 .. code-block:: bash
 
     $ pytest --version
-    This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.7/site-packages/pytest.py
+    This is pytest version 5.x.y, imported from $PYTHON_PREFIX/lib/python3.6/site-packages/pytest.py
 
 .. _`simpletest`:
 

From bd68c2a3dca6e6aadd1f9a0e4810f53256d4f6a8 Mon Sep 17 00:00:00 2001
From: Michael Shields <michael.shields@freenome.com>
Date: Tue, 12 Nov 2019 02:02:47 +0000
Subject: [PATCH 10/14] Update advice about _called_from_test.

Instead of giving an example of using sys and then, at the end,
advising not to use sys, just give a correct example. This is
especially helpful since mypy 0.740 has started (correctly) complaining
about sys._called_from_pytest not being present.
---
 doc/en/example/simple.rst | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/doc/en/example/simple.rst b/doc/en/example/simple.rst
index a7cd06d31..05ccbc9b2 100644
--- a/doc/en/example/simple.rst
+++ b/doc/en/example/simple.rst
@@ -300,36 +300,33 @@ behave differently if called from a test.  But if you
 absolutely must find out if your application code is
 running from a test you can do something like this:
 
+.. code-block:: python
+
+    # content of your_module.py
+
+
+    _called_from_test = False
+
 .. code-block:: python
 
     # content of conftest.py
 
 
     def pytest_configure(config):
-        import sys
+        your_module._called_from_test = True
 
-        sys._called_from_test = True
-
-
-    def pytest_unconfigure(config):
-        import sys
-
-        del sys._called_from_test
-
-and then check for the ``sys._called_from_test`` flag:
+and then check for the ``your_module._called_from_test`` flag:
 
 .. code-block:: python
 
-    if hasattr(sys, "_called_from_test"):
+    if your_module._called_from_test:
         # called from within a test run
         ...
     else:
         # called "normally"
         ...
 
-accordingly in your application.  It's also a good idea
-to use your own application module rather than ``sys``
-for handling flag.
+accordingly in your application.
 
 Adding info to test report header
 --------------------------------------------------------------

From dd9a27cf543c39f91039ecd7aa6aa595b3e79330 Mon Sep 17 00:00:00 2001
From: Bruno Oliveira <nicoddemus@gmail.com>
Date: Thu, 14 Nov 2019 13:35:51 -0300
Subject: [PATCH 11/14] Adjust CHANGELOG

---
 CHANGELOG.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 402a35d73..87ffb9e07 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -24,7 +24,7 @@ pytest 5.2.3 (2019-11-14)
 Bug Fixes
 ---------
 
-- `#5830 <https://github.com/pytest-dev/pytest/issues/5830>`_: Fix fail skipping the first test in package marked as ``skip``
+- `#5830 <https://github.com/pytest-dev/pytest/issues/5830>`_: The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.
 
 
 - `#6099 <https://github.com/pytest-dev/pytest/issues/6099>`_: Fix ``--trace`` when used with parametrized functions.

From 176c7771fb4f3bd703bb6c9650cc32e31d548a2b Mon Sep 17 00:00:00 2001
From: Anthony Sottile <asottile@umich.edu>
Date: Fri, 15 Nov 2019 08:29:52 -0800
Subject: [PATCH 12/14] Revert "fix bug with nonskipped first test in package
 (#5831)"

This reverts commit 85288b53218d4e0037dce9c34bd37f86fa9e212d, reversing
changes made to 5f9db8a01721e10162769b96b82794dd069bbaeb.
---
 AUTHORS                  |  1 -
 src/_pytest/python.py    | 24 ++++++------------------
 testing/test_skipping.py | 23 -----------------------
 3 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index d0e584f63..e11400c1f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -70,7 +70,6 @@ Daniel Hahler
 Daniel Nuri
 Daniel Wandschneider
 Danielle Jenkins
-Daniil Galiev
 Dave Hunt
 David Díaz-Barquero
 David Mohr
diff --git a/src/_pytest/python.py b/src/_pytest/python.py
index 306e5f217..b8b365ad3 100644
--- a/src/_pytest/python.py
+++ b/src/_pytest/python.py
@@ -251,21 +251,18 @@ class PyobjMixin(PyobjContext):
     @property
     def obj(self):
         """Underlying Python object."""
-        self._mount_obj_if_needed()
-        return self._obj
-
-    @obj.setter
-    def obj(self, value):
-        self._obj = value
-
-    def _mount_obj_if_needed(self):
         obj = getattr(self, "_obj", None)
         if obj is None:
             self._obj = obj = self._getobj()
             # XXX evil hack
             # used to avoid Instance collector marker duplication
             if self._ALLOW_MARKERS:
-                self.own_markers.extend(get_unpacked_marks(obj))
+                self.own_markers.extend(get_unpacked_marks(self.obj))
+        return obj
+
+    @obj.setter
+    def obj(self, value):
+        self._obj = value
 
     def _getobj(self):
         """Gets the underlying Python object. May be overwritten by subclasses."""
@@ -432,14 +429,6 @@ class PyCollector(PyobjMixin, nodes.Collector):
 class Module(nodes.File, PyCollector):
     """ Collector for test classes and functions. """
 
-    def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
-        if fspath.basename == "__init__.py":
-            self._ALLOW_MARKERS = False
-
-        nodes.FSCollector.__init__(
-            self, fspath, parent=parent, config=config, session=session, nodeid=nodeid
-        )
-
     def _getobj(self):
         return self._importtestmodule()
 
@@ -639,7 +628,6 @@ class Package(Module):
         return path in self.session._initialpaths
 
     def collect(self):
-        self._mount_obj_if_needed()
         this_path = self.fspath.dirpath()
         init_module = this_path.join("__init__.py")
         if init_module.check(file=1) and path_matches_patterns(
diff --git a/testing/test_skipping.py b/testing/test_skipping.py
index 371c3a4db..8bba479f1 100644
--- a/testing/test_skipping.py
+++ b/testing/test_skipping.py
@@ -1162,26 +1162,3 @@ def test_importorskip():
         match="^could not import 'doesnotexist': No module named .*",
     ):
         pytest.importorskip("doesnotexist")
-
-
-def test_skip_package(testdir):
-    testdir.makepyfile(
-        __init__="""
-        import pytest
-        pytestmark = pytest.mark.skip
-    """
-    )
-
-    testdir.makepyfile(
-        """
-        import pytest
-        def test_skip1():
-            assert 0
-        def test_skip2():
-            assert 0
-    """
-    )
-
-    result = testdir.inline_run()
-    _, skipped, _ = result.listoutcomes()
-    assert len(skipped) == 2

From 4e0f99260d438d750b55a0881110658b8bba5a4a Mon Sep 17 00:00:00 2001
From: Anthony Sottile <asottile@umich.edu>
Date: Fri, 15 Nov 2019 08:31:53 -0800
Subject: [PATCH 13/14] Add regression tests for __init__.py breakage

---
 AUTHORS                    |  1 +
 changelog/6194.bugfix.rst  |  1 +
 changelog/6197.bugfix.rst  |  1 +
 testing/test_collection.py | 21 +++++++++++++++++++++
 4 files changed, 24 insertions(+)
 create mode 100644 changelog/6194.bugfix.rst
 create mode 100644 changelog/6197.bugfix.rst

diff --git a/AUTHORS b/AUTHORS
index e11400c1f..d0e584f63 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -70,6 +70,7 @@ Daniel Hahler
 Daniel Nuri
 Daniel Wandschneider
 Danielle Jenkins
+Daniil Galiev
 Dave Hunt
 David Díaz-Barquero
 David Mohr
diff --git a/changelog/6194.bugfix.rst b/changelog/6194.bugfix.rst
new file mode 100644
index 000000000..92e6aec78
--- /dev/null
+++ b/changelog/6194.bugfix.rst
@@ -0,0 +1 @@
+Fix incorrect discovery of non-test ``__init__.py`` files.
diff --git a/changelog/6197.bugfix.rst b/changelog/6197.bugfix.rst
new file mode 100644
index 000000000..9bd0a5a65
--- /dev/null
+++ b/changelog/6197.bugfix.rst
@@ -0,0 +1 @@
+Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.".
diff --git a/testing/test_collection.py b/testing/test_collection.py
index dee07d5c7..8050e80f9 100644
--- a/testing/test_collection.py
+++ b/testing/test_collection.py
@@ -1257,3 +1257,24 @@ def test_collector_respects_tbstyle(testdir):
             "*= 1 error in *",
         ]
     )
+
+
+def test_does_not_eagerly_collect_packages(testdir):
+    testdir.makepyfile("def test(): pass")
+    pydir = testdir.mkpydir("foopkg")
+    pydir.join("__init__.py").write("assert False")
+    result = testdir.runpytest()
+    assert result.ret == ExitCode.OK
+
+
+def test_does_not_put_src_on_path(testdir):
+    # `src` is not on sys.path so it should not be importable
+    testdir.tmpdir.join("src/nope/__init__.py").ensure()
+    testdir.makepyfile(
+        "import pytest\n"
+        "def test():\n"
+        "    with pytest.raises(ImportError):\n"
+        "        import nope\n"
+    )
+    result = testdir.runpytest()
+    assert result.ret == ExitCode.OK

From c9a96cdee8ee7c1a9ead49b355fab9aef73196fe Mon Sep 17 00:00:00 2001
From: Anthony Sottile <asottile@umich.edu>
Date: Fri, 15 Nov 2019 13:24:35 -0800
Subject: [PATCH 14/14] Preparing release version 5.2.4

---
 CHANGELOG.rst                     | 12 ++++++++++++
 changelog/6194.bugfix.rst         |  1 -
 changelog/6197.bugfix.rst         |  1 -
 doc/en/announce/index.rst         |  1 +
 doc/en/announce/release-5.2.4.rst | 22 ++++++++++++++++++++++
 doc/en/example/parametrize.rst    |  7 +++----
 6 files changed, 38 insertions(+), 6 deletions(-)
 delete mode 100644 changelog/6194.bugfix.rst
 delete mode 100644 changelog/6197.bugfix.rst
 create mode 100644 doc/en/announce/release-5.2.4.rst

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 87ffb9e07..b1a988de8 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -18,6 +18,18 @@ with advance notice in the **Deprecations** section of releases.
 
 .. towncrier release notes start
 
+pytest 5.2.4 (2019-11-15)
+=========================
+
+Bug Fixes
+---------
+
+- `#6194 <https://github.com/pytest-dev/pytest/issues/6194>`_: Fix incorrect discovery of non-test ``__init__.py`` files.
+
+
+- `#6197 <https://github.com/pytest-dev/pytest/issues/6197>`_: Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.".
+
+
 pytest 5.2.3 (2019-11-14)
 =========================
 
diff --git a/changelog/6194.bugfix.rst b/changelog/6194.bugfix.rst
deleted file mode 100644
index 92e6aec78..000000000
--- a/changelog/6194.bugfix.rst
+++ /dev/null
@@ -1 +0,0 @@
-Fix incorrect discovery of non-test ``__init__.py`` files.
diff --git a/changelog/6197.bugfix.rst b/changelog/6197.bugfix.rst
deleted file mode 100644
index 9bd0a5a65..000000000
--- a/changelog/6197.bugfix.rst
+++ /dev/null
@@ -1 +0,0 @@
-Revert "The first test in a package (``__init__.py``) marked with ``@pytest.mark.skip`` is now correctly skipped.".
diff --git a/doc/en/announce/index.rst b/doc/en/announce/index.rst
index 05530dd2e..e7c011411 100644
--- a/doc/en/announce/index.rst
+++ b/doc/en/announce/index.rst
@@ -6,6 +6,7 @@ Release announcements
    :maxdepth: 2
 
 
+   release-5.2.4
    release-5.2.3
    release-5.2.2
    release-5.2.1
diff --git a/doc/en/announce/release-5.2.4.rst b/doc/en/announce/release-5.2.4.rst
new file mode 100644
index 000000000..05677e77f
--- /dev/null
+++ b/doc/en/announce/release-5.2.4.rst
@@ -0,0 +1,22 @@
+pytest-5.2.4
+=======================================
+
+pytest 5.2.4 has just been released to PyPI.
+
+This is a bug-fix release, being a drop-in replacement. To upgrade::
+
+  pip install --upgrade pytest
+
+The full changelog is available at https://docs.pytest.org/en/latest/changelog.html.
+
+Thanks to all who contributed to this release, among them:
+
+* Anthony Sottile
+* Bruno Oliveira
+* Daniel Hahler
+* Hugo
+* Michael Shields
+
+
+Happy testing,
+The pytest Development Team
diff --git a/doc/en/example/parametrize.rst b/doc/en/example/parametrize.rst
index 48ab95fda..0e131dace 100644
--- a/doc/en/example/parametrize.rst
+++ b/doc/en/example/parametrize.rst
@@ -475,11 +475,10 @@ Running it results in some skips if we don't have all the python interpreters in
 .. code-block:: pytest
 
    . $ pytest -rs -q multipython.py
-   ssssssssssss...ssssssssssss                                          [100%]
+   ssssssssssss......sss......                                          [100%]
    ========================= short test summary info ==========================
-   SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
-   SKIPPED [12] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.7' not found
-   3 passed, 24 skipped in 0.12s
+   SKIPPED [15] $REGENDOC_TMPDIR/CWD/multipython.py:30: 'python3.5' not found
+   12 passed, 15 skipped in 0.12s
 
 Indirect parametrization of optional implementations/imports
 --------------------------------------------------------------------