{"instance_id": "pytest-dev__pytest-5262", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py\nindex 25eab7fdf..2f3d71286 100644\n--- a/src/_pytest/capture.py\n+++ b/src/_pytest/capture.py\n@@ -447,6 +447,11 @@ class EncodedFile(object):\n         \"\"\"Ensure that file.name is a string.\"\"\"\n         return repr(self.buffer)\n \n+    @property\n+    def mode(self):\n+        \"\"\"Advertise a text mode: strip the binary flag of the underlying buffer.\"\"\"\n+        return self.buffer.mode.replace(\"b\", \"\")\n+\n     def __getattr__(self, name):\n         return getattr(object.__getattribute__(self, \"buffer\"), name)\n \n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 16, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 16, "steps": 6}, {"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 16, "steps": 6}], "ms": 22625}
{"instance_id": "pytest-dev__pytest-5787", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/src/_pytest/reports.py b/src/_pytest/reports.py\nindex 4682d5b6e..cd9ac8fa3 100644\n--- a/src/_pytest/reports.py\n+++ b/src/_pytest/reports.py\n@@ -3,6 +3,7 @@ from typing import Optional\n \n import py\n \n+from _pytest._code.code import ExceptionChainRepr\n from _pytest._code.code import ExceptionInfo\n from _pytest._code.code import ReprEntry\n from _pytest._code.code import ReprEntryNative\n@@ -162,28 +163,43 @@ class BaseReport:\n         \"\"\"\n \n         def disassembled_report(rep):\n-            reprtraceback = rep.longrepr.reprtraceback.__dict__.copy()\n-            reprcrash = rep.longrepr.reprcrash.__dict__.copy()\n-\n-            new_entries = []\n-            for entry in reprtraceback[\"reprentries\"]:\n-                entry_data = {\n-                    \"type\": type(entry).__name__,\n-                    \"data\": entry.__dict__.copy(),\n-                }\n-                for key, value in entry_data[\"data\"].items():\n-                    if hasattr(value, \"__dict__\"):\n-                        entry_data[\"data\"][key] = value.__dict__.copy()\n-                new_entries.append(entry_data)\n-\n-            reprtraceback[\"reprentries\"] = new_entries\n-\n-            return {\n-                \"reprcrash\": reprcrash,\n-                \"reprtraceback\": reprtraceback,\n+            def serialize_repr_traceback(reprtraceback):\n+                result = reprtraceback.__dict__.copy()\n+                new_entries = []\n+                for entry in result[\"reprentries\"]:\n+                    entry_data = {\n+                        \"type\": type(entry).__name__,\n+                        \"data\": entry.__dict__.copy(),\n+                    }\n+                    for key, value in entry_data[\"data\"].items():\n+                        if hasattr(value, \"__dict__\"):\n+                            entry_data[\"data\"][key] = value.__dict__.copy()\n+                    new_entries.append(entry_data)\n+                result[\"reprentries\"] = new_entries\n+                return result\n+\n+            def serialize_repr_crash(reprcrash):\n+                if reprcrash is None:\n+                    return None\n+                return reprcrash.__dict__.copy()\n+\n+            result = {\n+                \"reprcrash\": serialize_repr_crash(rep.longrepr.reprcrash),\n+                \"reprtraceback\": serialize_repr_traceback(rep.longrepr.reprtraceback),\n                 \"sections\": rep.longrepr.sections,\n             }\n \n+            if hasattr(rep.longrepr, \"chain\"):\n+                result[\"chain\"] = [\n+                    (\n+                        serialize_repr_traceback(reprtraceback),\n+                        serialize_repr_crash(reprcrash),\n+                        descr,\n+                    )\n+                    for reprtraceback, reprcrash, descr in rep.longrepr.chain\n+                ]\n+            return result\n+\n         d = self.__dict__.copy()\n         if hasattr(self.longrepr, \"toterminal\"):\n             if hasattr(self.longrepr, \"reprtraceback\") and hasattr(\n@@ -217,43 +233,61 @@ class BaseReport:\n                 and \"reprtraceback\" in reportdict[\"longrepr\"]\n             ):\n \n-                reprtraceback = reportdict[\"longrepr\"][\"reprtraceback\"]\n+                def deserialize_repr_entries(reprtraceback):\n+                    unserialized_entries = []\n+                    reprentry = None\n+                    for entry_data in reprtraceback[\"reprentries\"]:\n+                        data = entry_data[\"data\"]\n+                        entry_type = entry_data[\"type\"]\n+                        if entry_type == \"ReprEntry\":\n+                            reprfuncargs = None\n+                            reprfileloc = None\n+                            reprlocals = None\n+                            if data[\"reprfuncargs\"]:\n+                                reprfuncargs = ReprFuncArgs(**data[\"reprfuncargs\"])\n+                            if data[\"reprfileloc\"]:\n+                                reprfileloc = ReprFileLocation(**data[\"reprfileloc\"])\n+                            if data[\"reprlocals\"]:\n+                                reprlocals = ReprLocals(data[\"reprlocals\"][\"lines\"])\n+\n+                            reprentry = ReprEntry(\n+                                lines=data[\"lines\"],\n+                                reprfuncargs=reprfuncargs,\n+                                reprlocals=reprlocals,\n+                                filelocrepr=reprfileloc,\n+                                style=data[\"style\"],\n+                            )\n+                        elif entry_type == \"ReprEntryNative\":\n+                            reprentry = ReprEntryNative(data[\"lines\"])\n+                        else:\n+                            _report_unserialization_failure(\n+                                entry_type, cls, reportdict\n+                            )\n+                        unserialized_entries.append(reprentry)\n+                    reprtraceback[\"reprentries\"] = unserialized_entries\n+                    return reprtraceback\n+\n+                reprtraceback = deserialize_repr_entries(\n+                    reportdict[\"longrepr\"][\"reprtraceback\"]\n+                )\n                 reprcrash = reportdict[\"longrepr\"][\"reprcrash\"]\n \n-                unserialized_entries = []\n-                reprentry = None\n-                for entry_data in reprtraceback[\"reprentries\"]:\n-                    data = entry_data[\"data\"]\n-                    entry_type = entry_data[\"type\"]\n-                    if entry_type == \"ReprEntry\":\n-                        reprfuncargs = None\n-                        reprfileloc = None\n-                        reprlocals = None\n-                        if data[\"reprfuncargs\"]:\n-                            reprfuncargs = ReprFuncArgs(**data[\"reprfuncargs\"])\n-                        if data[\"reprfileloc\"]:\n-                            reprfileloc = ReprFileLocation(**data[\"reprfileloc\"])\n-                        if data[\"reprlocals\"]:\n-                            reprlocals = ReprLocals(data[\"reprlocals\"][\"lines\"])\n-\n-                        reprentry = ReprEntry(\n-                            lines=data[\"lines\"],\n-                            reprfuncargs=reprfuncargs,\n-                            reprlocals=reprlocals,\n-                            filelocrepr=reprfileloc,\n-                            style=data[\"style\"],\n+                if \"chain\" in reportdict[\"longrepr\"]:\n+                    chain = []\n+                    for tb_data, crash_data, descr in reportdict[\"longrepr\"][\"chain\"]:\n+                        chain.append(\n+                            (\n+                                ReprTraceback(**deserialize_repr_entries(tb_data)),\n+                                ReprFileLocation(**crash_data) if crash_data else None,\n+                                descr,\n+                            )\n                         )\n-                    elif entry_type == \"ReprEntryNative\":\n-                        reprentry = ReprEntryNative(data[\"lines\"])\n-                    else:\n-                        _report_unserialization_failure(entry_type, cls, reportdict)\n-                    unserialized_entries.append(reprentry)\n-                reprtraceback[\"reprentries\"] = unserialized_entries\n-\n-                exception_info = ReprExceptionInfo(\n-                    reprtraceback=ReprTraceback(**reprtraceback),\n-                    reprcrash=ReprFileLocation(**reprcrash),\n-                )\n+                    exception_info = ExceptionChainRepr(chain)\n+                else:\n+                    exception_info = ReprExceptionInfo(\n+                        reprtraceback=ReprTraceback(**reprtraceback),\n+                        reprcrash=ReprFileLocation(**reprcrash),\n+                    )\n \n                 for section in reportdict[\"longrepr\"][\"sections\"]:\n                     exception_info.addsection(*section)\n", "model": "claude-sonnet-5-5", "steps": 18, "finished": false, "patch_lines": 171, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 171, "steps": 18}], "ms": 56706}
{"instance_id": "pytest-dev__pytest-5840", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py\nindex 3a0eca546..591423d8c 100644\n--- a/src/_pytest/config/__init__.py\n+++ b/src/_pytest/config/__init__.py\n@@ -30,7 +30,6 @@ from _pytest._code import filter_traceback\n from _pytest.compat import importlib_metadata\n from _pytest.outcomes import fail\n from _pytest.outcomes import Skipped\n-from _pytest.pathlib import unique_path\n from _pytest.warning_types import PytestConfigWarning\n \n hookimpl = HookimplMarker(\"pytest\")\n@@ -367,7 +366,7 @@ class PytestPluginManager(PluginManager):\n         \"\"\"\n         current = py.path.local()\n         self._confcutdir = (\n-            unique_path(current.join(namespace.confcutdir, abs=True))\n+            current.join(namespace.confcutdir, abs=True).realpath()\n             if namespace.confcutdir\n             else None\n         )\n@@ -406,7 +405,7 @@ class PytestPluginManager(PluginManager):\n         else:\n             directory = path\n \n-        directory = unique_path(directory)\n+        directory = directory.realpath()\n \n         # XXX these days we may rather want to use config.rootdir\n         # and allow users to opt into looking into the rootdir parent\n@@ -435,7 +434,7 @@ class PytestPluginManager(PluginManager):\n         # Use realpath to avoid loading the same conftest twice\n         # with build systems that create build directories containing\n         # symlinks to actual files.\n-        conftestpath = unique_path(conftestpath)\n+        conftestpath = conftestpath.realpath()\n         try:\n             return self._conftestpath2mod[conftestpath]\n         except KeyError:\n", "model": "claude-sonnet-5-5", "steps": 10, "finished": true, "patch_lines": 39, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 39, "steps": 10}], "ms": 28175}
{"instance_id": "pytest-dev__pytest-6202", "model_name_or_path": "cain-70b-e124", "model_patch": "diff --git a/src/_pytest/python.py b/src/_pytest/python.py\nindex b8b365ad3..b4a9bcab3 100644\n--- a/src/_pytest/python.py\n+++ b/src/_pytest/python.py\n@@ -1,1445 +1 @@\n-\"\"\" Python test discovery, setup and run of test functions. \"\"\"\n-import enum\n-import fnmatch\n-import inspect\n-import os\n-import sys\n-import warnings\n-from collections import Counter\n-from collections.abc import Sequence\n-from functools import partial\n-from textwrap import dedent\n-\n-import py\n-\n-import _pytest\n-from _pytest import fixtures\n-from _pytest import nodes\n-from _pytest._code import filter_traceback\n-from _pytest.compat import ascii_escaped\n-from _pytest.compat import get_default_arg_names\n-from _pytest.compat import get_real_func\n-from _pytest.compat import getfslineno\n-from _pytest.compat import getimfunc\n-from _pytest.compat import getlocation\n-from _pytest.compat import is_generator\n-from _pytest.compat import iscoroutinefunction\n-from _pytest.compat import NOTSET\n-from _pytest.compat import REGEX_TYPE\n-from _pytest.compat import safe_getattr\n-from _pytest.compat import safe_isclass\n-from _pytest.compat import STRING_TYPES\n-from _pytest.config import hookimpl\n-from _pytest.main import FSHookProxy\n-from _pytest.mark import MARK_GEN\n-from _pytest.mark.structures import get_unpacked_marks\n-from _pytest.mark.structures import normalize_mark_list\n-from _pytest.outcomes import fail\n-from _pytest.outcomes import skip\n-from _pytest.pathlib import parts\n-from _pytest.warning_types import PytestCollectionWarning\n-from _pytest.warning_types import PytestUnhandledCoroutineWarning\n-\n-\n-def pyobj_property(name):\n-    def get(self):\n-        node = self.getparent(getattr(__import__(\"pytest\"), name))\n-        if node is not None:\n-            return node.obj\n-\n-    doc = \"python {} object this node was collected from (can be None).\".format(\n-        name.lower()\n-    )\n-    return property(get, None, None, doc)\n-\n-\n-def pytest_addoption(parser):\n-    group = parser.getgroup(\"general\")\n-    group.addoption(\n-        \"--fixtures\",\n-        \"--funcargs\",\n-        action=\"store_true\",\n-        dest=\"showfixtures\",\n-        default=False,\n-        help=\"show available fixtures, sorted by plugin appearance \"\n-        \"(fixtures with leading '_' are only shown with '-v')\",\n-    )\n-    group.addoption(\n-        \"--fixtures-per-test\",\n-        action=\"store_true\",\n-        dest=\"show_fixtures_per_test\",\n-        default=False,\n-        help=\"show fixtures per test\",\n-    )\n-    parser.addini(\n-        \"python_files\",\n-        type=\"args\",\n-        # NOTE: default is also used in AssertionRewritingHook.\n-        default=[\"test_*.py\", \"*_test.py\"],\n-        help=\"glob-style file patterns for Python test module discovery\",\n-    )\n-    parser.addini(\n-        \"python_classes\",\n-        type=\"args\",\n-        default=[\"Test\"],\n-        help=\"prefixes or glob names for Python test class discovery\",\n-    )\n-    parser.addini(\n-        \"python_functions\",\n-        type=\"args\",\n-        default=[\"test\"],\n-        help=\"prefixes or glob names for Python test function and method discovery\",\n-    )\n-    parser.addini(\n-        \"disable_test_id_escaping_and_forfeit_all_rights_to_community_support\",\n-        type=\"bool\",\n-        default=False,\n-        help=\"disable string escape non-ascii characters, might cause unwanted \"\n-        \"side effects(use at your own risk)\",\n-    )\n-\n-    group.addoption(\n-        \"--import-mode\",\n-        default=\"prepend\",\n-        choices=[\"prepend\", \"append\"],\n-        dest=\"importmode\",\n-        help=\"prepend/append to sys.path when importing test modules, \"\n-        \"default is to prepend.\",\n-    )\n-\n-\n-def pytest_cmdline_main(config):\n-    if config.option.showfixtures:\n-        showfixtures(config)\n-        return 0\n-    if config.option.show_fixtures_per_test:\n-        show_fixtures_per_test(config)\n-        return 0\n-\n-\n-def pytest_generate_tests(metafunc):\n-    # those alternative spellings are common - raise a specific error to alert\n-    # the user\n-    alt_spellings = [\"parameterize\", \"parametrise\", \"parameterise\"]\n-    for mark_name in alt_spellings:\n-        if metafunc.definition.get_closest_marker(mark_name):\n-            msg = \"{0} has '{1}' mark, spelling should be 'parametrize'\"\n-            fail(msg.format(metafunc.function.__name__, mark_name), pytrace=False)\n-    for marker in metafunc.definition.iter_markers(name=\"parametrize\"):\n-        metafunc.parametrize(*marker.args, **marker.kwargs)\n-\n-\n-def pytest_configure(config):\n-    config.addinivalue_line(\n-        \"markers\",\n-        \"parametrize(argnames, argvalues): call a test function multiple \"\n-        \"times passing in different arguments in turn. argvalues generally \"\n-        \"needs to be a list of values if argnames specifies only one name \"\n-        \"or a list of tuples of values if argnames specifies multiple names. \"\n-        \"Example: @parametrize('arg1', [1,2]) would lead to two calls of the \"\n-        \"decorated test function, one with arg1=1 and another with arg1=2.\"\n-        \"see https://docs.pytest.org/en/latest/parametrize.html for more info \"\n-        \"and examples.\",\n-    )\n-    config.addinivalue_line(\n-        \"markers\",\n-        \"usefixtures(fixturename1, fixturename2, ...): mark tests as needing \"\n-        \"all of the specified fixtures. see \"\n-        \"https://docs.pytest.org/en/latest/fixture.html#usefixtures \",\n-    )\n-\n-\n-@hookimpl(trylast=True)\n-def pytest_pyfunc_call(pyfuncitem):\n-    def async_warn():\n-        msg = \"async def functions are not natively supported and have been skipped.\\n\"\n-        msg += \"You need to install a suitable plugin for your async framework, for example:\\n\"\n-        msg += \"  - pytest-asyncio\\n\"\n-        msg += \"  - pytest-trio\\n\"\n-        msg += \"  - pytest-tornasync\"\n-        warnings.warn(PytestUnhandledCoroutineWarning(msg.format(pyfuncitem.nodeid)))\n-        skip(msg=\"async def function and no async plugin installed (see warnings)\")\n-\n-    testfunction = pyfuncitem.obj\n-    if iscoroutinefunction(testfunction) or (\n-        sys.version_info >= (3, 6) and inspect.isasyncgenfunction(testfunction)\n-    ):\n-        async_warn()\n-    funcargs = pyfuncitem.funcargs\n-    testargs = {arg: funcargs[arg] for arg in pyfuncitem._fixtureinfo.argnames}\n-    result = testfunction(**testargs)\n-    if hasattr(result, \"__await__\") or hasattr(result, \"__aiter__\"):\n-        async_warn()\n-    return True\n-\n-\n-def pytest_collect_file(path, parent):\n-    ext = path.ext\n-    if ext == \".py\":\n-        if not parent.session.isinitpath(path):\n-            if not path_matches_patterns(\n-                path, parent.config.getini(\"python_files\") + [\"__init__.py\"]\n-            ):\n-                return\n-        ihook = parent.session.gethookproxy(path)\n-        return ihook.pytest_pycollect_makemodule(path=path, parent=parent)\n-\n-\n-def path_matches_patterns(path, patterns):\n-    \"\"\"Returns True if the given py.path.local matches one of the patterns in the list of globs given\"\"\"\n-    return any(path.fnmatch(pattern) for pattern in patterns)\n-\n-\n-def pytest_pycollect_makemodule(path, parent):\n-    if path.basename == \"__init__.py\":\n-        return Package(path, parent)\n-    return Module(path, parent)\n-\n-\n-@hookimpl(hookwrapper=True)\n-def pytest_pycollect_makeitem(collector, name, obj):\n-    outcome = yield\n-    res = outcome.get_result()\n-    if res is not None:\n-        return\n-    # nothing was collected elsewhere, let's do it here\n-    if safe_isclass(obj):\n-        if collector.istestclass(obj, name):\n-            outcome.force_result(Class(name, parent=collector))\n-    elif collector.istestfunction(obj, name):\n-        # mock seems to store unbound methods (issue473), normalize it\n-        obj = getattr(obj, \"__func__\", obj)\n-        # We need to try and unwrap the function if it's a functools.partial\n-        # or a functools.wrapped.\n-        # We mustn't if it's been wrapped with mock.patch (python 2 only)\n-        if not (inspect.isfunction(obj) or inspect.isfunction(get_real_func(obj))):\n-            filename, lineno = getfslineno(obj)\n-            warnings.warn_explicit(\n-                message=PytestCollectionWarning(\n-                    \"cannot collect %r because it is not a function.\" % name\n-                ),\n-                category=None,\n-                filename=str(filename),\n-                lineno=lineno + 1,\n-            )\n-        elif getattr(obj, \"__test__\", True):\n-            if is_generator(obj):\n-                res = Function(name, parent=collector)\n-                reason = \"yield tests were removed in pytest 4.0 - {name} will be ignored\".format(\n-                    name=name\n-                )\n-                res.add_marker(MARK_GEN.xfail(run=False, reason=reason))\n-                res.warn(PytestCollectionWarning(reason))\n-            else:\n-                res = list(collector._genfunctions(name, obj))\n-            outcome.force_result(res)\n-\n-\n-def pytest_make_parametrize_id(config, val, argname=None):\n-    return None\n-\n-\n-class PyobjContext:\n-    module = pyobj_property(\"Module\")\n-    cls = pyobj_property(\"Class\")\n-    instance = pyobj_property(\"Instance\")\n-\n-\n-class PyobjMixin(PyobjContext):\n-    _ALLOW_MARKERS = True\n-\n-    @property\n-    def obj(self):\n-        \"\"\"Underlying Python object.\"\"\"\n-        obj = getattr(self, \"_obj\", None)\n-        if obj is None:\n-            self._obj = obj = self._getobj()\n-            # XXX evil hack\n-            # used to avoid Instance collector marker duplication\n-            if self._ALLOW_MARKERS:\n-                self.own_markers.extend(get_unpacked_marks(self.obj))\n-        return obj\n-\n-    @obj.setter\n-    def obj(self, value):\n-        self._obj = value\n-\n-    def _getobj(self):\n-        \"\"\"Gets the underlying Python object. May be overwritten by subclasses.\"\"\"\n-        return getattr(self.parent.obj, self.name)\n-\n-    def getmodpath(self, stopatmodule=True, includemodule=False):\n-        \"\"\" return python path relative to the containing module. \"\"\"\n-        chain = self.listchain()\n-        chain.reverse()\n-        parts = []\n-        for node in chain:\n-            if isinstance(node, Instance):\n-                continue\n-            name = node.name\n-            if isinstance(node, Module):\n-                name = os.path.splitext(name)[0]\n-                if stopatmodule:\n-                    if includemodule:\n-                        parts.append(name)\n-                    break\n-            parts.append(name)\n-        parts.reverse()\n-        s = \".\".join(parts)\n-        return s.replace(\".[\", \"[\")\n-\n-    def reportinfo(self):\n-        # XXX caching?\n-        obj = self.obj\n-        compat_co_firstlineno = getattr(obj, \"compat_co_firstlineno\", None)\n-        if isinstance(compat_co_firstlineno, int):\n-            # nose compatibility\n-            fspath = sys.modules[obj.__module__].__file__\n-            if fspath.endswith(\".pyc\"):\n-                fspath = fspath[:-1]\n-            lineno = compat_co_firstlineno\n-        else:\n-            fspath, lineno = getfslineno(obj)\n-        modpath = self.getmodpath()\n-        assert isinstance(lineno, int)\n-        return fspath, lineno, modpath\n-\n-\n-class PyCollector(PyobjMixin, nodes.Collector):\n-    def funcnamefilter(self, name):\n-        return self._matches_prefix_or_glob_option(\"python_functions\", name)\n-\n-    def isnosetest(self, obj):\n-        \"\"\" Look for the __test__ attribute, which is applied by the\n-        @nose.tools.istest decorator\n-        \"\"\"\n-        # We explicitly check for \"is True\" here to not mistakenly treat\n-        # classes with a custom __getattr__ returning something truthy (like a\n-        # function) as test classes.\n-        return safe_getattr(obj, \"__test__\", False) is True\n-\n-    def classnamefilter(self, name):\n-        return self._matches_prefix_or_glob_option(\"python_classes\", name)\n-\n-    def istestfunction(self, obj, name):\n-        if self.funcnamefilter(name) or self.isnosetest(obj):\n-            if isinstance(obj, staticmethod):\n-                # static methods need to be unwrapped\n-                obj = safe_getattr(obj, \"__func__\", False)\n-            return (\n-                safe_getattr(obj, \"__call__\", False)\n-                and fixtures.getfixturemarker(obj) is None\n-            )\n-        else:\n-            return False\n-\n-    def istestclass(self, obj, name):\n-        return self.classnamefilter(name) or self.isnosetest(obj)\n-\n-    def _matches_prefix_or_glob_option(self, option_name, name):\n-        \"\"\"\n-        checks if the given name matches the prefix or glob-pattern defined\n-        in ini configuration.\n-        \"\"\"\n-        for option in self.config.getini(option_name):\n-            if name.startswith(option):\n-                return True\n-            # check that name looks like a glob-string before calling fnmatch\n-            # because this is called for every name in each collected module,\n-            # and fnmatch is somewhat expensive to call\n-            elif (\"*\" in option or \"?\" in option or \"[\" in option) and fnmatch.fnmatch(\n-                name, option\n-            ):\n-                return True\n-        return False\n-\n-    def collect(self):\n-        if not getattr(self.obj, \"__test__\", True):\n-            return []\n-\n-        # NB. we avoid random getattrs and peek in the __dict__ instead\n-        # (XXX originally introduced from a PyPy need, still true?)\n-        dicts = [getattr(self.obj, \"__dict__\", {})]\n-        for basecls in inspect.getmro(self.obj.__class__):\n-            dicts.append(basecls.__dict__)\n-        seen = {}\n-        values = []\n-        for dic in dicts:\n-            for name, obj in list(dic.items()):\n-                if name in seen:\n-                    continue\n-                seen[name] = True\n-                res = self._makeitem(name, obj)\n-                if res is None:\n-                    continue\n-                if not isinstance(res, list):\n-                    res = [res]\n-                values.extend(res)\n-        values.sort(key=lambda item: item.reportinfo()[:2])\n-        return values\n-\n-    def _makeitem(self, name, obj):\n-        # assert self.ihook.fspath == self.fspath, self\n-        return self.ihook.pytest_pycollect_makeitem(collector=self, name=name, obj=obj)\n-\n-    def _genfunctions(self, name, funcobj):\n-        module = self.getparent(Module).obj\n-        clscol = self.getparent(Class)\n-        cls = clscol and clscol.obj or None\n-        fm = self.session._fixturemanager\n-\n-        definition = FunctionDefinition(name=name, parent=self, callobj=funcobj)\n-        fixtureinfo = fm.getfixtureinfo(definition, funcobj, cls)\n-\n-        metafunc = Metafunc(\n-            definition, fixtureinfo, self.config, cls=cls, module=module\n-        )\n-        methods = []\n-        if hasattr(module, \"pytest_generate_tests\"):\n-            methods.append(module.pytest_generate_tests)\n-        if hasattr(cls, \"pytest_generate_tests\"):\n-            methods.append(cls().pytest_generate_tests)\n-\n-        self.ihook.pytest_generate_tests.call_extra(methods, dict(metafunc=metafunc))\n-\n-        if not metafunc._calls:\n-            yield Function(name, parent=self, fixtureinfo=fixtureinfo)\n-        else:\n-            # add funcargs() as fixturedefs to fixtureinfo.arg2fixturedefs\n-            fixtures.add_funcarg_pseudo_fixture_def(self, metafunc, fm)\n-\n-            # add_funcarg_pseudo_fixture_def may have shadowed some fixtures\n-            # with direct parametrization, so make sure we update what the\n-            # function really needs.\n-            fixtureinfo.prune_dependency_tree()\n-\n-            for callspec in metafunc._calls:\n-                subname = \"{}[{}]\".format(name, callspec.id)\n-                yield Function(\n-                    name=subname,\n-                    parent=self,\n-                    callspec=callspec,\n-                    callobj=funcobj,\n-                    fixtureinfo=fixtureinfo,\n-                    keywords={callspec.id: True},\n-                    originalname=name,\n-                )\n-\n-\n-class Module(nodes.File, PyCollector):\n-    \"\"\" Collector for test classes and functions. \"\"\"\n-\n-    def _getobj(self):\n-        return self._importtestmodule()\n-\n-    def collect(self):\n-        self._inject_setup_module_fixture()\n-        self._inject_setup_function_fixture()\n-        self.session._fixturemanager.parsefactories(self)\n-        return super().collect()\n-\n-    def _inject_setup_module_fixture(self):\n-        \"\"\"Injects a hidden autouse, module scoped fixture into the collected module object\n-        that invokes setUpModule/tearDownModule if either or both are available.\n-\n-        Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with\n-        other fixtures (#517).\n-        \"\"\"\n-        setup_module = _get_first_non_fixture_func(\n-            self.obj, (\"setUpModule\", \"setup_module\")\n-        )\n-        teardown_module = _get_first_non_fixture_func(\n-            self.obj, (\"tearDownModule\", \"teardown_module\")\n-        )\n-\n-        if setup_module is None and teardown_module is None:\n-            return\n-\n-        @fixtures.fixture(autouse=True, scope=\"module\")\n-        def xunit_setup_module_fixture(request):\n-            if setup_module is not None:\n-                _call_with_optional_argument(setup_module, request.module)\n-            yield\n-            if teardown_module is not None:\n-                _call_with_optional_argument(teardown_module, request.module)\n-\n-        self.obj.__pytest_setup_module = xunit_setup_module_fixture\n-\n-    def _inject_setup_function_fixture(self):\n-        \"\"\"Injects a hidden autouse, function scoped fixture into the collected module object\n-        that invokes setup_function/teardown_function if either or both are available.\n-\n-        Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with\n-        other fixtures (#517).\n-        \"\"\"\n-        setup_function = _get_first_non_fixture_func(self.obj, (\"setup_function\",))\n-        teardown_function = _get_first_non_fixture_func(\n-            self.obj, (\"teardown_function\",)\n-        )\n-        if setup_function is None and teardown_function is None:\n-            return\n-\n-        @fixtures.fixture(autouse=True, scope=\"function\")\n-        def xunit_setup_function_fixture(request):\n-            if request.instance is not None:\n-                # in this case we are bound to an instance, so we need to let\n-                # setup_method handle this\n-                yield\n-                return\n-            if setup_function is not None:\n-                _call_with_optional_argument(setup_function, request.function)\n-            yield\n-            if teardown_function is not None:\n-                _call_with_optional_argument(teardown_function, request.function)\n-\n-        self.obj.__pytest_setup_function = xunit_setup_function_fixture\n-\n-    def _importtestmodule(self):\n-        # we assume we are only called once per module\n-        importmode = self.config.getoption(\"--import-mode\")\n-        try:\n-            mod = self.fspath.pyimport(ensuresyspath=importmode)\n-        except SyntaxError:\n-            raise self.CollectError(\n-                _pytest._code.ExceptionInfo.from_current().getrepr(style=\"short\")\n-            )\n-        except self.fspath.ImportMismatchError:\n-            e = sys.exc_info()[1]\n-            raise self.CollectError(\n-                \"import file mismatch:\\n\"\n-                \"imported module %r has this __file__ attribute:\\n\"\n-                \"  %s\\n\"\n-                \"which is not the same as the test file we want to collect:\\n\"\n-                \"  %s\\n\"\n-                \"HINT: remove __pycache__ / .pyc files and/or use a \"\n-                \"unique basename for your test file modules\" % e.args\n-            )\n-        except ImportError:\n-            from _pytest._code.code import ExceptionInfo\n-\n-            exc_info = ExceptionInfo.from_current()\n-            if self.config.getoption(\"verbose\") < 2:\n-                exc_info.traceback = exc_info.traceback.filter(filter_traceback)\n-            exc_repr = (\n-                exc_info.getrepr(style=\"short\")\n-                if exc_info.traceback\n-                else exc_info.exconly()\n-            )\n-            formatted_tb = str(exc_repr)\n-            raise self.CollectError(\n-                \"ImportError while importing test module '{fspath}'.\\n\"\n-                \"Hint: make sure your test modules/packages have valid Python names.\\n\"\n-                \"Traceback:\\n\"\n-                \"{traceback}\".format(fspath=self.fspath, traceback=formatted_tb)\n-            )\n-        except _pytest.runner.Skipped as e:\n-            if e.allow_module_level:\n-                raise\n-            raise self.CollectError(\n-                \"Using pytest.skip outside of a test is not allowed. \"\n-                \"To decorate a test function, use the @pytest.mark.skip \"\n-                \"or @pytest.mark.skipif decorators instead, and to skip a \"\n-                \"module use `pytestmark = pytest.mark.{skip,skipif}.\"\n-            )\n-        self.config.pluginmanager.consider_module(mod)\n-        return mod\n-\n-\n-class Package(Module):\n-    def __init__(self, fspath, parent=None, config=None, session=None, nodeid=None):\n-        session = parent.session\n-        nodes.FSCollector.__init__(\n-            self, fspath, parent=parent, config=config, session=session, nodeid=nodeid\n-        )\n-        self.name = fspath.dirname\n-        self.trace = session.trace\n-        self._norecursepatterns = session._norecursepatterns\n-        self.fspath = fspath\n-\n-    def setup(self):\n-        # not using fixtures to call setup_module here because autouse fixtures\n-        # from packages are not called automatically (#4085)\n-        setup_module = _get_first_non_fixture_func(\n-            self.obj, (\"setUpModule\", \"setup_module\")\n-        )\n-        if setup_module is not None:\n-            _call_with_optional_argument(setup_module, self.obj)\n-\n-        teardown_module = _get_first_non_fixture_func(\n-            self.obj, (\"tearDownModule\", \"teardown_module\")\n-        )\n-        if teardown_module is not None:\n-            func = partial(_call_with_optional_argument, teardown_module, self.obj)\n-            self.addfinalizer(func)\n-\n-    def _recurse(self, dirpath):\n-        if dirpath.basename == \"__pycache__\":\n-            return False\n-        ihook = self.gethookproxy(dirpath.dirpath())\n-        if ihook.pytest_ignore_collect(path=dirpath, config=self.config):\n-            return\n-        for pat in self._norecursepatterns:\n-            if dirpath.check(fnmatch=pat):\n-                return False\n-        ihook = self.gethookproxy(dirpath)\n-        ihook.pytest_collect_directory(path=dirpath, parent=self)\n-        return True\n-\n-    def gethookproxy(self, fspath):\n-        # check if we have the common case of running\n-        # hooks with all conftest.py filesall conftest.py\n-        pm = self.config.pluginmanager\n-        my_conftestmodules = pm._getconftestmodules(fspath)\n-        remove_mods = pm._conftest_plugins.difference(my_conftestmodules)\n-        if remove_mods:\n-            # one or more conftests are not in use at this fspath\n-            proxy = FSHookProxy(fspath, pm, remove_mods)\n-        else:\n-            # all plugins are active for this fspath\n-            proxy = self.config.hook\n-        return proxy\n-\n-    def _collectfile(self, path, handle_dupes=True):\n-        assert (\n-            path.isfile()\n-        ), \"{!r} is not a file (isdir={!r}, exists={!r}, islink={!r})\".format(\n-            path, path.isdir(), path.exists(), path.islink()\n-        )\n-        ihook = self.gethookproxy(path)\n-        if not self.isinitpath(path):\n-            if ihook.pytest_ignore_collect(path=path, config=self.config):\n-                return ()\n-\n-        if handle_dupes:\n-            keepduplicates = self.config.getoption(\"keepduplicates\")\n-            if not keepduplicates:\n-                duplicate_paths = self.config.pluginmanager._duplicatepaths\n-                if path in duplicate_paths:\n-                    return ()\n-                else:\n-                    duplicate_paths.add(path)\n-\n-        if self.fspath == path:  # __init__.py\n-            return [self]\n-\n-        return ihook.pytest_collect_file(path=path, parent=self)\n-\n-    def isinitpath(self, path):\n-        return path in self.session._initialpaths\n-\n-    def collect(self):\n-        this_path = self.fspath.dirpath()\n-        init_module = this_path.join(\"__init__.py\")\n-        if init_module.check(file=1) and path_matches_patterns(\n-            init_module, self.config.getini(\"python_files\")\n-        ):\n-            yield Module(init_module, self)\n-        pkg_prefixes = set()\n-        for path in this_path.visit(rec=self._recurse, bf=True, sort=True):\n-            # We will visit our own __init__.py file, in which case we skip it.\n-            is_file = path.isfile()\n-            if is_file:\n-                if path.basename == \"__init__.py\" and path.dirpath() == this_path:\n-                    continue\n-\n-            parts_ = parts(path.strpath)\n-            if any(\n-                pkg_prefix in parts_ and pkg_prefix.join(\"__init__.py\") != path\n-                for pkg_prefix in pkg_prefixes\n-            ):\n-                continue\n-\n-            if is_file:\n-                yield from self._collectfile(path)\n-            elif not path.isdir():\n-                # Broken symlink or invalid/missing file.\n-                continue\n-            elif path.join(\"__init__.py\").check(file=1):\n-                pkg_prefixes.add(path)\n-\n-\n-def _call_with_optional_argument(func, arg):\n-    \"\"\"Call the given function with the given argument if func accepts one argument, otherwise\n-    calls func without arguments\"\"\"\n-    arg_count = func.__code__.co_argcount\n-    if inspect.ismethod(func):\n-        arg_count -= 1\n-    if arg_count:\n-        func(arg)\n-    else:\n-        func()\n-\n-\n-def _get_first_non_fixture_func(obj, names):\n-    \"\"\"Return the attribute from the given object to be used as a setup/teardown\n-    xunit-style function, but only if not marked as a fixture to\n-    avoid calling it twice.\n-    \"\"\"\n-    for name in names:\n-        meth = getattr(obj, name, None)\n-        if meth is not None and fixtures.getfixturemarker(meth) is None:\n-            return meth\n-\n-\n-class Class(PyCollector):\n-    \"\"\" Collector for test methods. \"\"\"\n-\n-    def collect(self):\n-        if not safe_getattr(self.obj, \"__test__\", True):\n-            return []\n-        if hasinit(self.obj):\n-            self.warn(\n-                PytestCollectionWarning(\n-                    \"cannot collect test class %r because it has a \"\n-                    \"__init__ constructor (from: %s)\"\n-                    % (self.obj.__name__, self.parent.nodeid)\n-                )\n-            )\n-            return []\n-        elif hasnew(self.obj):\n-            self.warn(\n-                PytestCollectionWarning(\n-                    \"cannot collect test class %r because it has a \"\n-                    \"__new__ constructor (from: %s)\"\n-                    % (self.obj.__name__, self.parent.nodeid)\n-                )\n-            )\n-            return []\n-\n-        self._inject_setup_class_fixture()\n-        self._inject_setup_method_fixture()\n-\n-        return [Instance(name=\"()\", parent=self)]\n-\n-    def _inject_setup_class_fixture(self):\n-        \"\"\"Injects a hidden autouse, class scoped fixture into the collected class object\n-        that invokes setup_class/teardown_class if either or both are available.\n-\n-        Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with\n-        other fixtures (#517).\n-        \"\"\"\n-        setup_class = _get_first_non_fixture_func(self.obj, (\"setup_class\",))\n-        teardown_class = getattr(self.obj, \"teardown_class\", None)\n-        if setup_class is None and teardown_class is None:\n-            return\n-\n-        @fixtures.fixture(autouse=True, scope=\"class\")\n-        def xunit_setup_class_fixture(cls):\n-            if setup_class is not None:\n-                func = getimfunc(setup_class)\n-                _call_with_optional_argument(func, self.obj)\n-            yield\n-            if teardown_class is not None:\n-                func = getimfunc(teardown_class)\n-                _call_with_optional_argument(func, self.obj)\n-\n-        self.obj.__pytest_setup_class = xunit_setup_class_fixture\n-\n-    def _inject_setup_method_fixture(self):\n-        \"\"\"Injects a hidden autouse, function scoped fixture into the collected class object\n-        that invokes setup_method/teardown_method if either or both are available.\n-\n-        Using a fixture to invoke this methods ensures we play nicely and unsurprisingly with\n-        other fixtures (#517).\n-        \"\"\"\n-        setup_method = _get_first_non_fixture_func(self.obj, (\"setup_method\",))\n-        teardown_method = getattr(self.obj, \"teardown_method\", None)\n-        if setup_method is None and teardown_method is None:\n-            return\n-\n-        @fixtures.fixture(autouse=True, scope=\"function\")\n-        def xunit_setup_method_fixture(self, request):\n-            method = request.function\n-            if setup_method is not None:\n-                func = getattr(self, \"setup_method\")\n-                _call_with_optional_argument(func, method)\n-            yield\n-            if teardown_method is not None:\n-                func = getattr(self, \"teardown_method\")\n-                _call_with_optional_argument(func, method)\n-\n-        self.obj.__pytest_setup_method = xunit_setup_method_fixture\n-\n-\n-class Instance(PyCollector):\n-    _ALLOW_MARKERS = False  # hack, destroy later\n-    # instances share the object with their parents in a way\n-    # that duplicates markers instances if not taken out\n-    # can be removed at node structure reorganization time\n-\n-    def _getobj(self):\n-        return self.parent.obj()\n-\n-    def collect(self):\n-        self.session._fixturemanager.parsefactories(self)\n-        return super().collect()\n-\n-    def newinstance(self):\n-        self.obj = self._getobj()\n-        return self.obj\n-\n-\n-class FunctionMixin(PyobjMixin):\n-    \"\"\" mixin for the code common to Function and Generator.\n-    \"\"\"\n-\n-    def setup(self):\n-        \"\"\" perform setup for this test function. \"\"\"\n-        if isinstance(self.parent, Instance):\n-            self.parent.newinstance()\n-            self.obj = self._getobj()\n-\n-    def _prunetraceback(self, excinfo):\n-        if hasattr(self, \"_obj\") and not self.config.getoption(\"fulltrace\", False):\n-            code = _pytest._code.Code(get_real_func(self.obj))\n-            path, firstlineno = code.path, code.firstlineno\n-            traceback = excinfo.traceback\n-            ntraceback = traceback.cut(path=path, firstlineno=firstlineno)\n-            if ntraceback == traceback:\n-                ntraceback = ntraceback.cut(path=path)\n-                if ntraceback == traceback:\n-                    ntraceback = ntraceback.filter(filter_traceback)\n-                    if not ntraceback:\n-                        ntraceback = traceback\n-\n-            excinfo.traceback = ntraceback.filter()\n-            # issue364: mark all but first and last frames to\n-            # only show a single-line message for each frame\n-            if self.config.getoption(\"tbstyle\", \"auto\") == \"auto\":\n-                if len(excinfo.traceback) > 2:\n-                    for entry in excinfo.traceback[1:-1]:\n-                        entry.set_repr_style(\"short\")\n-\n-    def repr_failure(self, excinfo, outerr=None):\n-        assert outerr is None, \"XXX outerr usage is deprecated\"\n-        style = self.config.getoption(\"tbstyle\", \"auto\")\n-        if style == \"auto\":\n-            style = \"long\"\n-        return self._repr_failure_py(excinfo, style=style)\n-\n-\n-def hasinit(obj):\n-    init = getattr(obj, \"__init__\", None)\n-    if init:\n-        return init != object.__init__\n-\n-\n-def hasnew(obj):\n-    new = getattr(obj, \"__new__\", None)\n-    if new:\n-        return new != object.__new__\n-\n-\n-class CallSpec2:\n-    def __init__(self, metafunc):\n-        self.metafunc = metafunc\n-        self.funcargs = {}\n-        self._idlist = []\n-        self.params = {}\n-        self._globalid = NOTSET\n-        self._globalparam = NOTSET\n-        self._arg2scopenum = {}  # used for sorting parametrized resources\n-        self.marks = []\n-        self.indices = {}\n-\n-    def copy(self):\n-        cs = CallSpec2(self.metafunc)\n-        cs.funcargs.update(self.funcargs)\n-        cs.params.update(self.params)\n-        cs.marks.extend(self.marks)\n-        cs.indices.update(self.indices)\n-        cs._arg2scopenum.update(self._arg2scopenum)\n-        cs._idlist = list(self._idlist)\n-        cs._globalid = self._globalid\n-        cs._globalparam = self._globalparam\n-        return cs\n-\n-    def _checkargnotcontained(self, arg):\n-        if arg in self.params or arg in self.funcargs:\n-            raise ValueError(\"duplicate {!r}\".format(arg))\n-\n-    def getparam(self, name):\n-        try:\n-            return self.params[name]\n-        except KeyError:\n-            if self._globalparam is NOTSET:\n-                raise ValueError(name)\n-            return self._globalparam\n-\n-    @property\n-    def id(self):\n-        return \"-\".join(map(str, filter(None, self._idlist)))\n-\n-    def setmulti2(self, valtypes, argnames, valset, id, marks, scopenum, param_index):\n-        for arg, val in zip(argnames, valset):\n-            self._checkargnotcontained(arg)\n-            valtype_for_arg = valtypes[arg]\n-            getattr(self, valtype_for_arg)[arg] = val\n-            self.indices[arg] = param_index\n-            self._arg2scopenum[arg] = scopenum\n-        self._idlist.append(id)\n-        self.marks.extend(normalize_mark_list(marks))\n-\n-\n-class Metafunc(fixtures.FuncargnamesCompatAttr):\n-    \"\"\"\n-    Metafunc objects are passed to the :func:`pytest_generate_tests <_pytest.hookspec.pytest_generate_tests>` hook.\n-    They help to inspect a test function and to generate tests according to\n-    test configuration or values specified in the class or module where a\n-    test function is defined.\n-    \"\"\"\n-\n-    def __init__(self, definition, fixtureinfo, config, cls=None, module=None):\n-        assert (\n-            isinstance(definition, FunctionDefinition)\n-            or type(definition).__name__ == \"DefinitionMock\"\n-        )\n-        self.definition = definition\n-\n-        #: access to the :class:`_pytest.config.Config` object for the test session\n-        self.config = config\n-\n-        #: the module object where the test function is defined in.\n-        self.module = module\n-\n-        #: underlying python test function\n-        self.function = definition.obj\n-\n-        #: set of fixture names required by the test function\n-        self.fixturenames = fixtureinfo.names_closure\n-\n-        #: class object where the test function is defined in or ``None``.\n-        self.cls = cls\n-\n-        self._calls = []\n-        self._ids = set()\n-        self._arg2fixturedefs = fixtureinfo.name2fixturedefs\n-\n-    def parametrize(self, argnames, argvalues, indirect=False, ids=None, scope=None):\n-        \"\"\" Add new invocations to the underlying test function using the list\n-        of argvalues for the given argnames.  Parametrization is performed\n-        during the collection phase.  If you need to setup expensive resources\n-        see about setting indirect to do it rather at test setup time.\n-\n-        :arg argnames: a comma-separated string denoting one or more argument\n-                       names, or a list/tuple of argument strings.\n-\n-        :arg argvalues: The list of argvalues determines how often a\n-            test is invoked with different argument values.  If only one\n-            argname was specified argvalues is a list of values.  If N\n-            argnames were specified, argvalues must be a list of N-tuples,\n-            where each tuple-element specifies a value for its respective\n-            argname.\n-\n-        :arg indirect: The list of argnames or boolean. A list of arguments'\n-            names (subset of argnames). If True the list contains all names from\n-            the argnames. Each argvalue corresponding to an argname in this list will\n-            be passed as request.param to its respective argname fixture\n-            function so that it can perform more expensive setups during the\n-            setup phase of a test rather than at collection time.\n-\n-        :arg ids: list of string ids, or a callable.\n-            If strings, each is corresponding to the argvalues so that they are\n-            part of the test id. If None is given as id of specific test, the\n-            automatically generated id for that argument will be used.\n-            If callable, it should take one argument (a single argvalue) and return\n-            a string or return None. If None, the automatically generated id for that\n-            argument will be used.\n-            If no ids are provided they will be generated automatically from\n-            the argvalues.\n-\n-        :arg scope: if specified it denotes the scope of the parameters.\n-            The scope is used for grouping tests by parameter instances.\n-            It will also override any fixture-function defined scope, allowing\n-            to set a dynamic scope using test context or configuration.\n-        \"\"\"\n-        from _pytest.fixtures import scope2index\n-        from _pytest.mark import ParameterSet\n-\n-        argnames, parameters = ParameterSet._for_parametrize(\n-            argnames,\n-            argvalues,\n-            self.function,\n-            self.config,\n-            function_definition=self.definition,\n-        )\n-        del argvalues\n-\n-        if \"request\" in argnames:\n-            fail(\n-                \"'request' is a reserved name and cannot be used in @pytest.mark.parametrize\",\n-                pytrace=False,\n-            )\n-\n-        if scope is None:\n-            scope = _find_parametrized_scope(argnames, self._arg2fixturedefs, indirect)\n-\n-        self._validate_if_using_arg_names(argnames, indirect)\n-\n-        arg_values_types = self._resolve_arg_value_types(argnames, indirect)\n-\n-        ids = self._resolve_arg_ids(argnames, ids, parameters, item=self.definition)\n-\n-        scopenum = scope2index(\n-            scope, descr=\"parametrize() call in {}\".format(self.function.__name__)\n-        )\n-\n-        # create the new calls: if we are parametrize() multiple times (by applying the decorator\n-        # more than once) then we accumulate those calls generating the cartesian product\n-        # of all calls\n-        newcalls = []\n-        for callspec in self._calls or [CallSpec2(self)]:\n-            for param_index, (param_id, param_set) in enumerate(zip(ids, parameters)):\n-                newcallspec = callspec.copy()\n-                newcallspec.setmulti2(\n-                    arg_values_types,\n-                    argnames,\n-                    param_set.values,\n-                    param_id,\n-                    param_set.marks,\n-                    scopenum,\n-                    param_index,\n-                )\n-                newcalls.append(newcallspec)\n-        self._calls = newcalls\n-\n-    def _resolve_arg_ids(self, argnames, ids, parameters, item):\n-        \"\"\"Resolves the actual ids for the given argnames, based on the ``ids`` parameter given\n-        to ``parametrize``.\n-\n-        :param List[str] argnames: list of argument names passed to ``parametrize()``.\n-        :param ids: the ids parameter of the parametrized call (see docs).\n-        :param List[ParameterSet] parameters: the list of parameter values, same size as ``argnames``.\n-        :param Item item: the item that generated this parametrized call.\n-        :rtype: List[str]\n-        :return: the list of ids for each argname given\n-        \"\"\"\n-        from _pytest._io.saferepr import saferepr\n-\n-        idfn = None\n-        if callable(ids):\n-            idfn = ids\n-            ids = None\n-        if ids:\n-            func_name = self.function.__name__\n-            if len(ids) != len(parameters):\n-                msg = \"In {}: {} parameter sets specified, with different number of ids: {}\"\n-                fail(msg.format(func_name, len(parameters), len(ids)), pytrace=False)\n-            for id_value in ids:\n-                if id_value is not None and not isinstance(id_value, str):\n-                    msg = \"In {}: ids must be list of strings, found: {} (type: {!r})\"\n-                    fail(\n-                        msg.format(func_name, saferepr(id_value), type(id_value)),\n-                        pytrace=False,\n-                    )\n-        ids = idmaker(argnames, parameters, idfn, ids, self.config, item=item)\n-        return ids\n-\n-    def _resolve_arg_value_types(self, argnames, indirect):\n-        \"\"\"Resolves if each parametrized argument must be considered a parameter to a fixture or a \"funcarg\"\n-        to the function, based on the ``indirect`` parameter of the parametrized() call.\n-\n-        :param List[str] argnames: list of argument names passed to ``parametrize()``.\n-        :param indirect: same ``indirect`` parameter of ``parametrize()``.\n-        :rtype: Dict[str, str]\n-            A dict mapping each arg name to either:\n-            * \"params\" if the argname should be the parameter of a fixture of the same name.\n-            * \"funcargs\" if the argname should be a parameter to the parametrized test function.\n-        \"\"\"\n-        if isinstance(indirect, bool):\n-            valtypes = dict.fromkeys(argnames, \"params\" if indirect else \"funcargs\")\n-        elif isinstance(indirect, Sequence):\n-            valtypes = dict.fromkeys(argnames, \"funcargs\")\n-            for arg in indirect:\n-                if arg not in argnames:\n-                    fail(\n-                        \"In {}: indirect fixture '{}' doesn't exist\".format(\n-                            self.function.__name__, arg\n-                        ),\n-                        pytrace=False,\n-                    )\n-                valtypes[arg] = \"params\"\n-        else:\n-            fail(\n-                \"In {func}: expected Sequence or boolean for indirect, got {type}\".format(\n-                    type=type(indirect).__name__, func=self.function.__name__\n-                ),\n-                pytrace=False,\n-            )\n-        return valtypes\n-\n-    def _validate_if_using_arg_names(self, argnames, indirect):\n-        \"\"\"\n-        Check if all argnames are being used, by default values, or directly/indirectly.\n-\n-        :param List[str] argnames: list of argument names passed to ``parametrize()``.\n-        :param indirect: same ``indirect`` parameter of ``parametrize()``.\n-        :raise ValueError: if validation fails.\n-        \"\"\"\n-        default_arg_names = set(get_default_arg_names(self.function))\n-        func_name = self.function.__name__\n-        for arg in argnames:\n-            if arg not in self.fixturenames:\n-                if arg in default_arg_names:\n-                    fail(\n-                        \"In {}: function already takes an argument '{}' with a default value\".format(\n-                            func_name, arg\n-                        ),\n-                        pytrace=False,\n-                    )\n-                else:\n-                    if isinstance(indirect, (tuple, list)):\n-                        name = \"fixture\" if arg in indirect else \"argument\"\n-                    else:\n-                        name = \"fixture\" if indirect else \"argument\"\n-                    fail(\n-                        \"In {}: function uses no {} '{}'\".format(func_name, name, arg),\n-                        pytrace=False,\n-                    )\n-\n-\n-def _find_parametrized_scope(argnames, arg2fixturedefs, indirect):\n-    \"\"\"Find the most appropriate scope for a parametrized call based on its arguments.\n-\n-    When there's at least one direct argument, always use \"function\" scope.\n-\n-    When a test function is parametrized and all its arguments are indirect\n-    (e.g. fixtures), return the most narrow scope based on the fixtures used.\n-\n-    Related to issue #1832, based on code posted by @Kingdread.\n-    \"\"\"\n-    from _pytest.fixtures import scopes\n-\n-    if isinstance(indirect, (list, tuple)):\n-        all_arguments_are_fixtures = len(indirect) == len(argnames)\n-    else:\n-        all_arguments_are_fixtures = bool(indirect)\n-\n-    if all_arguments_are_fixtures:\n-        fixturedefs = arg2fixturedefs or {}\n-        used_scopes = [\n-            fixturedef[0].scope\n-            for name, fixturedef in fixturedefs.items()\n-            if name in argnames\n-        ]\n-        if used_scopes:\n-            # Takes the most narrow scope from used fixtures\n-            for scope in reversed(scopes):\n-                if scope in used_scopes:\n-                    return scope\n-\n-    return \"function\"\n-\n-\n-def _ascii_escaped_by_config(val, config):\n-    if config is None:\n-        escape_option = False\n-    else:\n-        escape_option = config.getini(\n-            \"disable_test_id_escaping_and_forfeit_all_rights_to_community_support\"\n-        )\n-    return val if escape_option else ascii_escaped(val)\n-\n-\n-def _idval(val, argname, idx, idfn, item, config):\n-    if idfn:\n-        try:\n-            generated_id = idfn(val)\n-            if generated_id is not None:\n-                val = generated_id\n-        except Exception as e:\n-            # See issue https://github.com/pytest-dev/pytest/issues/2169\n-            msg = \"{}: error raised while trying to determine id of parameter '{}' at position {}\\n\"\n-            msg = msg.format(item.nodeid, argname, idx)\n-            raise ValueError(msg) from e\n-    elif config:\n-        hook_id = config.hook.pytest_make_parametrize_id(\n-            config=config, val=val, argname=argname\n-        )\n-        if hook_id:\n-            return hook_id\n-\n-    if isinstance(val, STRING_TYPES):\n-        return _ascii_escaped_by_config(val, config)\n-    elif val is None or isinstance(val, (float, int, bool)):\n-        return str(val)\n-    elif isinstance(val, REGEX_TYPE):\n-        return ascii_escaped(val.pattern)\n-    elif isinstance(val, enum.Enum):\n-        return str(val)\n-    elif (inspect.isclass(val) or inspect.isfunction(val)) and hasattr(val, \"__name__\"):\n-        return val.__name__\n-    return str(argname) + str(idx)\n-\n-\n-def _idvalset(idx, parameterset, argnames, idfn, ids, item, config):\n-    if parameterset.id is not None:\n-        return parameterset.id\n-    if ids is None or (idx >= len(ids) or ids[idx] is None):\n-        this_id = [\n-            _idval(val, argname, idx, idfn, item=item, config=config)\n-            for val, argname in zip(parameterset.values, argnames)\n-        ]\n-        return \"-\".join(this_id)\n-    else:\n-        return _ascii_escaped_by_config(ids[idx], config)\n-\n-\n-def idmaker(argnames, parametersets, idfn=None, ids=None, config=None, item=None):\n-    ids = [\n-        _idvalset(valindex, parameterset, argnames, idfn, ids, config=config, item=item)\n-        for valindex, parameterset in enumerate(parametersets)\n-    ]\n-    if len(set(ids)) != len(ids):\n-        # The ids are not unique\n-        duplicates = [testid for testid in ids if ids.count(testid) > 1]\n-        counters = Counter()\n-        for index, testid in enumerate(ids):\n-            if testid in duplicates:\n-                ids[index] = testid + str(counters[testid])\n-                counters[testid] += 1\n-    return ids\n-\n-\n-def show_fixtures_per_test(config):\n-    from _pytest.main import wrap_session\n-\n-    return wrap_session(config, _show_fixtures_per_test)\n-\n-\n-def _show_fixtures_per_test(config, session):\n-    import _pytest.config\n-\n-    session.perform_collect()\n-    curdir = py.path.local()\n-    tw = _pytest.config.create_terminal_writer(config)\n-    verbose = config.getvalue(\"verbose\")\n-\n-    def get_best_relpath(func):\n-        loc = getlocation(func, curdir)\n-        return curdir.bestrelpath(loc)\n-\n-    def write_fixture(fixture_def):\n-        argname = fixture_def.argname\n-        if verbose <= 0 and argname.startswith(\"_\"):\n-            return\n-        if verbose > 0:\n-            bestrel = get_best_relpath(fixture_def.func)\n-            funcargspec = \"{} -- {}\".format(argname, bestrel)\n-        else:\n-            funcargspec = argname\n-        tw.line(funcargspec, green=True)\n-        fixture_doc = fixture_def.func.__doc__\n-        if fixture_doc:\n-            write_docstring(tw, fixture_doc)\n-        else:\n-            tw.line(\"    no docstring available\", red=True)\n-\n-    def write_item(item):\n-        try:\n-            info = item._fixtureinfo\n-        except AttributeError:\n-            # doctests items have no _fixtureinfo attribute\n-            return\n-        if not info.name2fixturedefs:\n-            # this test item does not use any fixtures\n-            return\n-        tw.line()\n-        tw.sep(\"-\", \"fixtures used by {}\".format(item.name))\n-        tw.sep(\"-\", \"({})\".format(get_best_relpath(item.function)))\n-        # dict key not used in loop but needed for sorting\n-        for _, fixturedefs in sorted(info.name2fixturedefs.items()):\n-            assert fixturedefs is not None\n-            if not fixturedefs:\n-                continue\n-            # last item is expected to be the one used by the test item\n-            write_fixture(fixturedefs[-1])\n-\n-    for session_item in session.items:\n-        write_item(session_item)\n-\n-\n-def showfixtures(config):\n-    from _pytest.main import wrap_session\n-\n-    return wrap_session(config, _showfixtures_main)\n-\n-\n-def _showfixtures_main(config, session):\n-    import _pytest.config\n-\n-    session.perform_collect()\n-    curdir = py.path.local()\n-    tw = _pytest.config.create_terminal_writer(config)\n-    verbose = config.getvalue(\"verbose\")\n-\n-    fm = session._fixturemanager\n-\n-    available = []\n-    seen = set()\n-\n-    for argname, fixturedefs in fm._arg2fixturedefs.items():\n-        assert fixturedefs is not None\n-        if not fixturedefs:\n-            continue\n-        for fixturedef in fixturedefs:\n-            loc = getlocation(fixturedef.func, curdir)\n-            if (fixturedef.argname, loc) in seen:\n-                continue\n-            seen.add((fixturedef.argname, loc))\n-            available.append(\n-                (\n-                    len(fixturedef.baseid),\n-                    fixturedef.func.__module__,\n-                    curdir.bestrelpath(loc),\n-                    fixturedef.argname,\n-                    fixturedef,\n-                )\n-            )\n-\n-    available.sort()\n-    currentmodule = None\n-    for baseid, module, bestrel, argname, fixturedef in available:\n-        if currentmodule != module:\n-            if not module.startswith(\"_pytest.\"):\n-                tw.line()\n-                tw.sep(\"-\", \"fixtures defined from {}\".format(module))\n-                currentmodule = module\n-        if verbose <= 0 and argname[0] == \"_\":\n-            continue\n-        tw.write(argname, green=True)\n-        if fixturedef.scope != \"function\":\n-            tw.write(\" [%s scope]\" % fixturedef.scope, cyan=True)\n-        if verbose > 0:\n-            tw.write(\" -- %s\" % bestrel, yellow=True)\n-        tw.write(\"\\n\")\n-        loc = getlocation(fixturedef.func, curdir)\n-        doc = fixturedef.func.__doc__ or \"\"\n-        if doc:\n-            write_docstring(tw, doc)\n-        else:\n-            tw.line(\"    {}: no docstring available\".format(loc), red=True)\n-        tw.line()\n-\n-\n-def write_docstring(tw, doc, indent=\"    \"):\n-    doc = doc.rstrip()\n-    if \"\\n\" in doc:\n-        firstline, rest = doc.split(\"\\n\", 1)\n-    else:\n-        firstline, rest = doc, \"\"\n-\n-    if firstline.strip():\n-        tw.line(indent + firstline.strip())\n-\n-    if rest:\n-        for line in dedent(rest).split(\"\\n\"):\n-            tw.write(indent + line + \"\\n\")\n-\n-\n-class Function(FunctionMixin, nodes.Item, fixtures.FuncargnamesCompatAttr):\n-    \"\"\" a Function Item is responsible for setting up and executing a\n-    Python test function.\n-    \"\"\"\n-\n-    # disable since functions handle it themselves\n-    _ALLOW_MARKERS = False\n-\n-    def __init__(\n-        self,\n-        name,\n-        parent,\n-        args=None,\n-        config=None,\n-        callspec=None,\n-        callobj=NOTSET,\n-        keywords=None,\n-        session=None,\n-        fixtureinfo=None,\n-        originalname=None,\n-    ):\n-        super().__init__(name, parent, config=config, session=session)\n-        self._args = args\n-        if callobj is not NOTSET:\n-            self.obj = callobj\n-\n-        self.keywords.update(self.obj.__dict__)\n-        self.own_markers.extend(get_unpacked_marks(self.obj))\n-        if callspec:\n-            self.callspec = callspec\n-            # this is total hostile and a mess\n-            # keywords are broken by design by now\n-            # this will be redeemed later\n-            for mark in callspec.marks:\n-                # feel free to cry, this was broken for years before\n-                # and keywords cant fix it per design\n-                self.keywords[mark.name] = mark\n-            self.own_markers.extend(normalize_mark_list(callspec.marks))\n-        if keywords:\n-            self.keywords.update(keywords)\n-\n-        # todo: this is a hell of a hack\n-        # https://github.com/pytest-dev/pytest/issues/4569\n-\n-        self.keywords.update(\n-            {\n-                mark.name: True\n-                for mark in self.iter_markers()\n-                if mark.name not in self.keywords\n-            }\n-        )\n-\n-        if fixtureinfo is None:\n-            fixtureinfo = self.session._fixturemanager.getfixtureinfo(\n-                self, self.obj, self.cls, funcargs=True\n-            )\n-        self._fixtureinfo = fixtureinfo\n-        self.fixturenames = fixtureinfo.names_closure\n-        self._initrequest()\n-\n-        #: original function name, without any decorations (for example\n-        #: parametrization adds a ``\"[...]\"`` suffix to function names).\n-        #:\n-        #: .. versionadded:: 3.0\n-        self.originalname = originalname\n-\n-    def _initrequest(self):\n-        self.funcargs = {}\n-        self._request = fixtures.FixtureRequest(self)\n-\n-    @property\n-    def function(self):\n-        \"underlying python 'function' object\"\n-        return getimfunc(self.obj)\n-\n-    def _getobj(self):\n-        name = self.name\n-        i = name.find(\"[\")  # parametrization\n-        if i != -1:\n-            name = name[:i]\n-        return getattr(self.parent.obj, name)\n-\n-    @property\n-    def _pyfuncitem(self):\n-        \"(compatonly) for code expecting pytest-2.2 style request objects\"\n-        return self\n-\n-    def runtest(self):\n-        \"\"\" execute the underlying test function. \"\"\"\n-        self.ihook.pytest_pyfunc_call(pyfuncitem=self)\n-\n-    def setup(self):\n-        super().setup()\n-        fixtures.fillfixtures(self)\n-\n-\n-class FunctionDefinition(Function):\n-    \"\"\"\n-    internal hack until we get actual definition nodes instead of the\n-    crappy metafunc hack\n-    \"\"\"\n-\n-    def runtest(self):\n-        raise RuntimeError(\"function definitions are not supposed to be used\")\n-\n-    setup = runtest\n+return s\n\\ No newline at end of file\n"}
{"instance_id": "pytest-dev__pytest-7205", "model_name_or_path": "cain-70b-e124", "model_patch": "diff --git a/src/_pytest/setuponly.py b/src/_pytest/setuponly.py\nindex c9cc589ff..e8b68a029 100644\n--- a/src/_pytest/setuponly.py\n+++ b/src/_pytest/setuponly.py\n@@ -1,80 +1 @@\n-import pytest\n-\n-\n-def pytest_addoption(parser):\n-    group = parser.getgroup(\"debugconfig\")\n-    group.addoption(\n-        \"--setuponly\",\n-        \"--setup-only\",\n-        action=\"store_true\",\n-        help=\"only setup fixtures, do not execute tests.\",\n-    )\n-    group.addoption(\n-        \"--setupshow\",\n-        \"--setup-show\",\n-        action=\"store_true\",\n-        help=\"show setup of fixtures while executing tests.\",\n-    )\n-\n-\n-@pytest.hookimpl(hookwrapper=True)\n-def pytest_fixture_setup(fixturedef, request):\n-    yield\n-    if request.config.option.setupshow:\n-        if hasattr(request, \"param\"):\n-            # Save the fixture parameter so ._show_fixture_action() can\n-            # display it now and during the teardown (in .finish()).\n-            if fixturedef.ids:\n-                if callable(fixturedef.ids):\n-                    fixturedef.cached_param = fixturedef.ids(request.param)\n-                else:\n-                    fixturedef.cached_param = fixturedef.ids[request.param_index]\n-            else:\n-                fixturedef.cached_param = request.param\n-        _show_fixture_action(fixturedef, \"SETUP\")\n-\n-\n-def pytest_fixture_post_finalizer(fixturedef) -> None:\n-    if fixturedef.cached_result is not None:\n-        config = fixturedef._fixturemanager.config\n-        if config.option.setupshow:\n-            _show_fixture_action(fixturedef, \"TEARDOWN\")\n-            if hasattr(fixturedef, \"cached_param\"):\n-                del fixturedef.cached_param\n-\n-\n-def _show_fixture_action(fixturedef, msg):\n-    config = fixturedef._fixturemanager.config\n-    capman = config.pluginmanager.getplugin(\"capturemanager\")\n-    if capman:\n-        capman.suspend_global_capture()\n-\n-    tw = config.get_terminal_writer()\n-    tw.line()\n-    tw.write(\" \" * 2 * fixturedef.scopenum)\n-    tw.write(\n-        \"{step} {scope} {fixture}\".format(\n-            step=msg.ljust(8),  # align the output to TEARDOWN\n-            scope=fixturedef.scope[0].upper(),\n-            fixture=fixturedef.argname,\n-        )\n-    )\n-\n-    if msg == \"SETUP\":\n-        deps = sorted(arg for arg in fixturedef.argnames if arg != \"request\")\n-        if deps:\n-            tw.write(\" (fixtures used: {})\".format(\", \".join(deps)))\n-\n-    if hasattr(fixturedef, \"cached_param\"):\n-        tw.write(\"[{}]\".format(fixturedef.cached_param))\n-\n-    tw.flush()\n-\n-    if capman:\n-        capman.resume_global_capture()\n-\n-\n-@pytest.hookimpl(tryfirst=True)\n-def pytest_cmdline_main(config):\n-    if config.option.setuponly:\n-        config.option.setupshow = True\n+tw.write('[{}]'.format(saferepr(fixturedef.cached_param)))\n\\ No newline at end of file\n"}
{"instance_id": "pytest-dev__pytest-7236", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py\nindex 773f545af..8512aff53 100644\n--- a/src/_pytest/unittest.py\n+++ b/src/_pytest/unittest.py\n@@ -220,7 +220,7 @@ class TestCaseFunction(Function):\n             # arguably we could always postpone tearDown(), but this changes the moment where the\n             # TestCase instance interacts with the results object, so better to only do it\n             # when absolutely needed\n-            if self.config.getoption(\"usepdb\"):\n+            if self.config.getoption(\"usepdb\") and not _is_skipped(self.obj):\n                 self._explicit_tearDown = self._testcase.tearDown\n                 setattr(self._testcase, \"tearDown\", lambda *args: None)\n \n@@ -293,6 +293,11 @@ def pytest_runtest_protocol(item):\n         yield\n \n \n+def _is_skipped(obj) -> bool:\n+    \"\"\"Return True if the given object has been marked with @unittest.skip.\"\"\"\n+    return bool(getattr(obj, \"__unittest_skip__\", False))\n+\n+\n def check_testcase_implements_trial_reporter(done=[]):\n     if done:\n         return\n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 25, "candidates": [{"compile_ok": 0, "loc_hits": 1, "files": 1, "diff_lines": 25, "steps": 6}], "ms": 12913}
{"instance_id": "pytest-dev__pytest-7324", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py\nindex 04c73411a..959533880 100644\n--- a/src/_pytest/mark/expression.py\n+++ b/src/_pytest/mark/expression.py\n@@ -33,6 +33,8 @@ if TYPE_CHECKING:\n     from typing import NoReturn\n \n \n+IDENT_PREFIX = \"$\"\n+\n __all__ = [\n     \"Expression\",\n     \"ParseError\",\n@@ -161,7 +163,7 @@ def not_expr(s: Scanner) -> ast.expr:\n         return ret\n     ident = s.accept(TokenType.IDENT)\n     if ident:\n-        return ast.Name(ident.value, ast.Load())\n+        return ast.Name(IDENT_PREFIX + ident.value, ast.Load())\n     s.reject((TokenType.NOT, TokenType.LPAREN, TokenType.IDENT))\n \n \n@@ -172,7 +174,7 @@ class MatcherAdapter(Mapping[str, bool]):\n         self.matcher = matcher\n \n     def __getitem__(self, key: str) -> bool:\n-        return self.matcher(key)\n+        return self.matcher(key[len(IDENT_PREFIX) :])\n \n     def __iter__(self) -> Iterator[str]:\n         raise NotImplementedError()\n", "model": "claude-sonnet-5-5", "steps": 7, "finished": true, "patch_lines": 31, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 31, "steps": 7}], "ms": 18367}
{"instance_id": "pytest-dev__pytest-7432", "model_name_or_path": "cain-70b-e124", "model_patch": "diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py\nindex 7bd975e5a..c3ebb1d67 100644\n--- a/src/_pytest/skipping.py\n+++ b/src/_pytest/skipping.py\n@@ -1,314 +1,8 @@\n-\"\"\" support for skip/xfail functions and markers. \"\"\"\n-import os\n-import platform\n-import sys\n-import traceback\n-from typing import Generator\n-from typing import Optional\n-from typing import Tuple\n-\n-import attr\n-\n-import _pytest._code\n-from _pytest.compat import TYPE_CHECKING\n-from _pytest.config import Config\n-from _pytest.config import hookimpl\n-from _pytest.config.argparsing import Parser\n-from _pytest.mark.structures import Mark\n-from _pytest.nodes import Item\n-from _pytest.outcomes import fail\n-from _pytest.outcomes import skip\n-from _pytest.outcomes import xfail\n-from _pytest.reports import BaseReport\n-from _pytest.runner import CallInfo\n-from _pytest.store import StoreKey\n-\n-if TYPE_CHECKING:\n-    from typing import Type\n-\n-\n-def pytest_addoption(parser: Parser) -> None:\n-    group = parser.getgroup(\"general\")\n-    group.addoption(\n-        \"--runxfail\",\n-        action=\"store_true\",\n-        dest=\"runxfail\",\n-        default=False,\n-        help=\"report the results of xfail tests as if they were not marked\",\n-    )\n-\n-    parser.addini(\n-        \"xfail_strict\",\n-        \"default for the strict parameter of xfail \"\n-        \"markers when not given explicitly (default: False)\",\n-        default=False,\n-        type=\"bool\",\n-    )\n-\n-\n-def pytest_configure(config: Config) -> None:\n-    if config.option.runxfail:\n-        # yay a hack\n-        import pytest\n-\n-        old = pytest.xfail\n-        config._cleanup.append(lambda: setattr(pytest, \"xfail\", old))\n-\n-        def nop(*args, **kwargs):\n-            pass\n-\n-        nop.Exception = xfail.Exception  # type: ignore[attr-defined] # noqa: F821\n-        setattr(pytest, \"xfail\", nop)\n-\n-    config.addinivalue_line(\n-        \"markers\",\n-        \"skip(reason=None): skip the given test function with an optional reason. \"\n-        'Example: skip(reason=\"no way of currently testing this\") skips the '\n-        \"test.\",\n-    )\n-    config.addinivalue_line(\n-        \"markers\",\n-        \"skipif(condition, ..., *, reason=...): \"\n-        \"skip the given test function if any of the conditions evaluate to True. \"\n-        \"Example: skipif(sys.platform == 'win32') skips the test if we are on the win32 platform. \"\n-        \"See https://docs.pytest.org/en/stable/reference.html#pytest-mark-skipif\",\n-    )\n-    config.addinivalue_line(\n-        \"markers\",\n-        \"xfail(condition, ..., *, reason=..., run=True, raises=None, strict=xfail_strict): \"\n-        \"mark the test function as an expected failure if any of the conditions \"\n-        \"evaluate to True. Optionally specify a reason for better reporting \"\n-        \"and run=False if you don't even want to execute the test function. \"\n-        \"If only specific exception(s) are expected, you can list them in \"\n-        \"raises, and if the test fails in other ways, it will be reported as \"\n-        \"a true failure. See https://docs.pytest.org/en/stable/reference.html#pytest-mark-xfail\",\n-    )\n-\n-\n-def evaluate_condition(item: Item, mark: Mark, condition: object) -> Tuple[bool, str]:\n-    \"\"\"Evaluate a single skipif/xfail condition.\n-\n-    If an old-style string condition is given, it is eval()'d, otherwise the\n-    condition is bool()'d. If this fails, an appropriately formatted pytest.fail\n-    is raised.\n-\n-    Returns (result, reason). The reason is only relevant if the result is True.\n-    \"\"\"\n-    # String condition.\n-    if isinstance(condition, str):\n-        globals_ = {\n-            \"os\": os,\n-            \"sys\": sys,\n-            \"platform\": platform,\n-            \"config\": item.config,\n-        }\n-        if hasattr(item, \"obj\"):\n-            globals_.update(item.obj.__globals__)  # type: ignore[attr-defined]\n-        try:\n-            condition_code = _pytest._code.compile(condition, mode=\"eval\")\n-            result = eval(condition_code, globals_)\n-        except SyntaxError as exc:\n-            msglines = [\n-                \"Error evaluating %r condition\" % mark.name,\n-                \"    \" + condition,\n-                \"    \" + \" \" * (exc.offset or 0) + \"^\",\n-                \"SyntaxError: invalid syntax\",\n-            ]\n-            fail(\"\\n\".join(msglines), pytrace=False)\n-        except Exception as exc:\n-            msglines = [\n-                \"Error evaluating %r condition\" % mark.name,\n-                \"    \" + condition,\n-                *traceback.format_exception_only(type(exc), exc),\n-            ]\n-            fail(\"\\n\".join(msglines), pytrace=False)\n-\n-    # Boolean condition.\n-    else:\n-        try:\n-            result = bool(condition)\n-        except Exception as exc:\n-            msglines = [\n-                \"Error evaluating %r condition as a boolean\" % mark.name,\n-                *traceback.format_exception_only(type(exc), exc),\n-            ]\n-            fail(\"\\n\".join(msglines), pytrace=False)\n-\n-    reason = mark.kwargs.get(\"reason\", None)\n-    if reason is None:\n-        if isinstance(condition, str):\n-            reason = \"condition: \" + condition\n-        else:\n-            # XXX better be checked at collection time\n-            msg = (\n-                \"Error evaluating %r: \" % mark.name\n-                + \"you need to specify reason=STRING when using booleans as conditions.\"\n-            )\n-            fail(msg, pytrace=False)\n-\n-    return result, reason\n-\n-\n-@attr.s(slots=True, frozen=True)\n-class Skip:\n-    \"\"\"The result of evaluate_skip_marks().\"\"\"\n-\n-    reason = attr.ib(type=str)\n-\n-\n-def evaluate_skip_marks(item: Item) -> Optional[Skip]:\n-    \"\"\"Evaluate skip and skipif marks on item, returning Skip if triggered.\"\"\"\n-    for mark in item.iter_markers(name=\"skipif\"):\n-        if \"condition\" not in mark.kwargs:\n-            conditions = mark.args\n-        else:\n-            conditions = (mark.kwargs[\"condition\"],)\n-\n-        # Unconditional.\n-        if not conditions:\n-            reason = mark.kwargs.get(\"reason\", \"\")\n-            return Skip(reason)\n-\n-        # If any of the conditions are true.\n-        for condition in conditions:\n-            result, reason = evaluate_condition(item, mark, condition)\n-            if result:\n-                return Skip(reason)\n-\n-    for mark in item.iter_markers(name=\"skip\"):\n-        if \"reason\" in mark.kwargs:\n-            reason = mark.kwargs[\"reason\"]\n-        elif mark.args:\n-            reason = mark.args[0]\n-        else:\n-            reason = \"unconditional skip\"\n-        return Skip(reason)\n-\n-    return None\n-\n-\n-@attr.s(slots=True, frozen=True)\n-class Xfail:\n-    \"\"\"The result of evaluate_xfail_marks().\"\"\"\n-\n-    reason = attr.ib(type=str)\n-    run = attr.ib(type=bool)\n-    strict = attr.ib(type=bool)\n-    raises = attr.ib(type=Optional[Tuple[\"Type[BaseException]\", ...]])\n-\n-\n-def evaluate_xfail_marks(item: Item) -> Optional[Xfail]:\n-    \"\"\"Evaluate xfail marks on item, returning Xfail if triggered.\"\"\"\n-    for mark in item.iter_markers(name=\"xfail\"):\n-        run = mark.kwargs.get(\"run\", True)\n-        strict = mark.kwargs.get(\"strict\", item.config.getini(\"xfail_strict\"))\n-        raises = mark.kwargs.get(\"raises\", None)\n-        if \"condition\" not in mark.kwargs:\n-            conditions = mark.args\n-        else:\n-            conditions = (mark.kwargs[\"condition\"],)\n-\n-        # Unconditional.\n-        if not conditions:\n-            reason = mark.kwargs.get(\"reason\", \"\")\n-            return Xfail(reason, run, strict, raises)\n-\n-        # If any of the conditions are true.\n-        for condition in conditions:\n-            result, reason = evaluate_condition(item, mark, condition)\n-            if result:\n-                return Xfail(reason, run, strict, raises)\n-\n-    return None\n-\n-\n-# Whether skipped due to skip or skipif marks.\n-skipped_by_mark_key = StoreKey[bool]()\n-# Saves the xfail mark evaluation. Can be refreshed during call if None.\n-xfailed_key = StoreKey[Optional[Xfail]]()\n-unexpectedsuccess_key = StoreKey[str]()\n-\n-\n-@hookimpl(tryfirst=True)\n-def pytest_runtest_setup(item: Item) -> None:\n-    item._store[skipped_by_mark_key] = False\n-\n-    skipped = evaluate_skip_marks(item)\n-    if skipped:\n-        item._store[skipped_by_mark_key] = True\n-        skip(skipped.reason)\n-\n-    if not item.config.option.runxfail:\n-        item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item)\n-        if xfailed and not xfailed.run:\n-            xfail(\"[NOTRUN] \" + xfailed.reason)\n-\n-\n-@hookimpl(hookwrapper=True)\n-def pytest_runtest_call(item: Item) -> Generator[None, None, None]:\n-    xfailed = item._store.get(xfailed_key, None)\n-    if xfailed is None:\n-        item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item)\n-\n-    if not item.config.option.runxfail:\n-        if xfailed and not xfailed.run:\n-            xfail(\"[NOTRUN] \" + xfailed.reason)\n-\n-    yield\n-\n-\n-@hookimpl(hookwrapper=True)\n-def pytest_runtest_makereport(item: Item, call: CallInfo[None]):\n-    outcome = yield\n-    rep = outcome.get_result()\n-    xfailed = item._store.get(xfailed_key, None)\n-    # unittest special case, see setting of unexpectedsuccess_key\n-    if unexpectedsuccess_key in item._store and rep.when == \"call\":\n-        reason = item._store[unexpectedsuccess_key]\n-        if reason:\n-            rep.longrepr = \"Unexpected success: {}\".format(reason)\n-        else:\n-            rep.longrepr = \"Unexpected success\"\n-        rep.outcome = \"failed\"\n-    elif item.config.option.runxfail:\n-        pass  # don't interfere\n-    elif call.excinfo and isinstance(call.excinfo.value, xfail.Exception):\n-        assert call.excinfo.value.msg is not None\n-        rep.wasxfail = \"reason: \" + call.excinfo.value.msg\n-        rep.outcome = \"skipped\"\n-    elif not rep.skipped and xfailed:\n+def pytest_runtest_makereport(item, call):\n+    if item.config.option.runxfail:\n+        # Handle --runxfail option\n         if call.excinfo:\n-            raises = xfailed.raises\n-            if raises is not None and not isinstance(call.excinfo.value, raises):\n-                rep.outcome = \"failed\"\n-            else:\n-                rep.outcome = \"skipped\"\n-                rep.wasxfail = xfailed.reason\n-        elif call.when == \"call\":\n-            if xfailed.strict:\n-                rep.outcome = \"failed\"\n-                rep.longrepr = \"[XPASS(strict)] \" + xfailed.reason\n-            else:\n-                rep.outcome = \"passed\"\n-                rep.wasxfail = xfailed.reason\n-    elif (\n-        item._store.get(skipped_by_mark_key, True)\n-        and rep.skipped\n-        and type(rep.longrepr) is tuple\n-    ):\n-        # skipped by mark.skipif; change the location of the failure\n-        # to point to the item definition, otherwise it will display\n-        # the location of where the skip exception was raised within pytest\n-        _, _, reason = rep.longrepr\n-        filename, line = item.reportinfo()[:2]\n-        assert line is not None\n-        rep.longrepr = str(filename), line + 1, reason\n-\n-\n-def pytest_report_teststatus(report: BaseReport) -> Optional[Tuple[str, str, str]]:\n-    if hasattr(report, \"wasxfail\"):\n-        if report.skipped:\n-            return \"xfailed\", \"x\", \"XFAIL\"\n-        elif report.passed:\n-            return \"xpassed\", \"X\", \"XPASS\"\n-    return None\n+            if isinstance(call.excinfo.value, skip.Exception):\n+                # If the test was skipped, report the skip location correctly\n+                call.location = item.location\n+    # ... rest of the code remains the same ...\n\\ No newline at end of file\n"}
{"instance_id": "pytest-dev__pytest-7490", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/src/_pytest/skipping.py b/src/_pytest/skipping.py\nindex 335e10996..2694a54ae 100644\n--- a/src/_pytest/skipping.py\n+++ b/src/_pytest/skipping.py\n@@ -256,6 +256,10 @@ def pytest_runtest_call(item: Item) -> Generator[None, None, None]:\n \n     yield\n \n+    # The test run may have added an xfail mark dynamically.\n+    if item._store.get(xfailed_key, None) is None:\n+        item._store[xfailed_key] = xfailed = evaluate_xfail_marks(item)\n+\n \n @hookimpl(hookwrapper=True)\n def pytest_runtest_makereport(item: Item, call: CallInfo[None]):\n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 15, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 15, "steps": 6}], "ms": 14616}
{"instance_id": "pytest-dev__pytest-7521", "model_name_or_path": "cain-anthropic-e124", "model_patch": "diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py\nindex 3f9c60fb9..f538b67ec 100644\n--- a/src/_pytest/capture.py\n+++ b/src/_pytest/capture.py\n@@ -388,6 +388,7 @@ class FDCaptureBinary:\n                 TemporaryFile(buffering=0),  # type: ignore[arg-type]\n                 encoding=\"utf-8\",\n                 errors=\"replace\",\n+                newline=\"\",\n                 write_through=True,\n             )\n             if targetfd in patchsysdict:\n", "model": "claude-sonnet-5-5", "steps": 6, "finished": true, "patch_lines": 12, "candidates": [{"compile_ok": 0, "loc_hits": 0, "files": 1, "diff_lines": 12, "steps": 6}], "ms": 8117}
