|
3 | 3 | import pytest
|
4 | 4 |
|
5 | 5 |
|
6 |
| -PYTEST_GTE_7_0 = ( |
7 |
| - hasattr(pytest, 'version_tuple') and pytest.version_tuple >= (7, 0) |
8 |
| -) |
9 |
| -PYTEST_GTE_5_4 = hasattr(pytest.Collector, 'from_parent') |
| 6 | +PYTEST_GTE_7_0 = getattr(pytest, 'version_tuple', (0, 0)) >= (7, 0) |
| 7 | +PYTEST_GTE_5_4 = PYTEST_GTE_7_0 or hasattr(pytest.Collector, 'from_parent') |
10 | 8 |
|
11 | 9 |
|
12 | 10 | def trace_function(funcobj, *args, **kwargs):
|
@@ -66,27 +64,28 @@ class DescribeBlock(pytest.Module):
|
66 | 64 |
|
67 | 65 | @classmethod
|
68 | 66 | def from_parent(cls, parent, obj):
|
| 67 | + """Construct a new node for the describe block""" |
69 | 68 | name = getattr(obj, '_mangled_name', obj.__name__)
|
70 | 69 | nodeid = parent.nodeid + '::' + name
|
71 | 70 | if PYTEST_GTE_7_0:
|
72 | 71 | self = super().from_parent(
|
73 |
| - parent=parent, path=parent.path, nodeid=nodeid, |
74 |
| - ) |
| 72 | + parent=parent, path=parent.path, nodeid=nodeid) |
75 | 73 | elif PYTEST_GTE_5_4:
|
76 | 74 | self = super().from_parent(
|
77 |
| - parent=parent, fspath=parent.fspath, nodeid=nodeid, |
78 |
| - ) |
| 75 | + parent=parent, fspath=parent.fspath, nodeid=nodeid) |
79 | 76 | else:
|
80 | 77 | self = cls(parent=parent, fspath=parent.fspath, nodeid=nodeid)
|
81 | 78 | self.name = name
|
82 | 79 | self.funcobj = obj
|
83 | 80 | return self
|
84 | 81 |
|
85 | 82 | def collect(self):
|
| 83 | + """Get list of children""" |
86 | 84 | self.session._fixturemanager.parsefactories(self)
|
87 | 85 | return super().collect()
|
88 | 86 |
|
89 | 87 | def _getobj(self):
|
| 88 | + """Get the underlying Python object""" |
90 | 89 | return self._importtestmodule()
|
91 | 90 |
|
92 | 91 | def _importtestmodule(self):
|
|
0 commit comments