diff --git a/CHANGELOG b/CHANGELOG index 516414442..6ba65c3c5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,8 @@ Changes between 2.2.1 and 2.2.2.dev - fix crash resulting from calling monkeypatch undo a second time - extend reports accepting kwargs to set arbitrary additional attributes this helps xdist serialization/deserialization of extended/customized reports +- fix issue115: make --collectonly robust against preparse failure + (missing files/directories) Changes between 2.2.0 and 2.2.1 ---------------------------------------- diff --git a/_pytest/main.py b/_pytest/main.py index f6354205b..7ac673cf3 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -410,6 +410,7 @@ class Session(FSCollector): self._notfound = [] self._initialpaths = set() self._initialparts = [] + self.items = items = [] for arg in args: parts = self._parsearg(arg) self._initialparts.append(parts) @@ -425,7 +426,6 @@ class Session(FSCollector): if not genitems: return rep.result else: - self.items = items = [] if rep.passed: for node in rep.result: self.items.extend(self.genitems(node)) diff --git a/testing/test_terminal.py b/testing/test_terminal.py index c0ee32f74..90ee95e2a 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -256,6 +256,17 @@ class TestCollectonly: *1 error* """).strip()) + def test_collectonly_missing_path(self, testdir): + """this checks issue 115, + failure in parseargs will cause session + not to have the items attribute + """ + result = testdir.runpytest("--collectonly", "uhm_missing_path") + assert result.ret == 3 + result.stderr.fnmatch_lines([ + '*ERROR: file not found*', + ]) + def test_repr_python_version(monkeypatch): try: