-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
Workaround for #3742
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -482,6 +482,8 @@ def collect(self): | |
self.trace.root.indent -= 1 | ||
|
||
def _collect(self, arg): | ||
from _pytest.python import Package | ||
|
||
names = self._parsearg(arg) | ||
argpath = names.pop(0) | ||
paths = [] | ||
|
@@ -503,7 +505,7 @@ def _collect(self, arg): | |
root = self._node_cache[pkginit] | ||
else: | ||
col = root._collectfile(pkginit) | ||
if col: | ||
if col and isinstance(col, Package): | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nicoddemus
Member
|
||
root = col[0] | ||
self._node_cache[root.fspath] = root | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
|
||
|
||
class CustomItem(pytest.Item, pytest.File): | ||
def runtest(self): | ||
pass | ||
|
||
|
||
def pytest_collect_file(path, parent): | ||
return CustomItem(path, parent) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def test(): | ||
pass |
The return value is actually the return value of pytest_collect_file hook which is always going to be a list (i.e. firstresult == False). That's basically equivalent to "if False:"