Skip to content

Commit 176c777

Browse files
committed
Revert "fix bug with nonskipped first test in package (#5831)"
This reverts commit 85288b5, reversing changes made to 5f9db8a.
1 parent e856638 commit 176c777

File tree

3 files changed

+6
-42
lines changed

3 files changed

+6
-42
lines changed

AUTHORS

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ Daniel Hahler
7070
Daniel Nuri
7171
Daniel Wandschneider
7272
Danielle Jenkins
73-
Daniil Galiev
7473
Dave Hunt
7574
David Díaz-Barquero
7675
David Mohr

src/_pytest/python.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -251,21 +251,18 @@ class PyobjMixin(PyobjContext):
251251
@property
252252
def obj(self):
253253
"""Underlying Python object."""
254-
self._mount_obj_if_needed()
255-
return self._obj
256-
257-
@obj.setter
258-
def obj(self, value):
259-
self._obj = value
260-
261-
def _mount_obj_if_needed(self):
262254
obj = getattr(self, "_obj", None)
263255
if obj is None:
264256
self._obj = obj = self._getobj()
265257
# XXX evil hack
266258
# used to avoid Instance collector marker duplication
267259
if self._ALLOW_MARKERS:
268-
self.own_markers.extend(get_unpacked_marks(obj))
260+
self.own_markers.extend(get_unpacked_marks(self.obj))
261+
return obj
262+
263+
@obj.setter
264+
def obj(self, value):
265+
self._obj = value
269266

270267
def _getobj(self):
271268
"""Gets the underlying Python object. May be overwritten by subclasses."""
@@ -432,14 +429,6 @@ def _genfunctions(self, name, funcobj):
432429
class Module(nodes.File, PyCollector):
433430
""" Collector for test classes and functions. """
434431

435-
def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):
436-
if fspath.basename == "__init__.py":
437-
self._ALLOW_MARKERS = False
438-
439-
nodes.FSCollector.__init__(
440-
self, fspath, parent=parent, config=config, session=session, nodeid=nodeid
441-
)
442-
443432
def _getobj(self):
444433
return self._importtestmodule()
445434

@@ -639,7 +628,6 @@ def isinitpath(self, path):
639628
return path in self.session._initialpaths
640629

641630
def collect(self):
642-
self._mount_obj_if_needed()
643631
this_path = self.fspath.dirpath()
644632
init_module = this_path.join("__init__.py")
645633
if init_module.check(file=1) and path_matches_patterns(

testing/test_skipping.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,26 +1162,3 @@ def test_importorskip():
11621162
match="^could not import 'doesnotexist': No module named .*",
11631163
):
11641164
pytest.importorskip("doesnotexist")
1165-
1166-
1167-
def test_skip_package(testdir):
1168-
testdir.makepyfile(
1169-
__init__="""
1170-
import pytest
1171-
pytestmark = pytest.mark.skip
1172-
"""
1173-
)
1174-
1175-
testdir.makepyfile(
1176-
"""
1177-
import pytest
1178-
def test_skip1():
1179-
assert 0
1180-
def test_skip2():
1181-
assert 0
1182-
"""
1183-
)
1184-
1185-
result = testdir.inline_run()
1186-
_, skipped, _ = result.listoutcomes()
1187-
assert len(skipped) == 2

0 commit comments

Comments
 (0)