File tree 2 files changed +6
-2
lines changed 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change
1
+ Cache node splitting function which can improve collection performance in very large test suites.
Original file line number Diff line number Diff line change 1
1
import os
2
2
import warnings
3
+ from functools import lru_cache
3
4
4
5
import py
5
6
13
14
tracebackcutdir = py .path .local (_pytest .__file__ ).dirpath ()
14
15
15
16
17
+ @lru_cache (maxsize = None )
16
18
def _splitnode (nodeid ):
17
19
"""Split a nodeid into constituent 'parts'.
18
20
@@ -30,11 +32,12 @@ def _splitnode(nodeid):
30
32
"""
31
33
if nodeid == "" :
32
34
# If there is no root node at all, return an empty list so the caller's logic can remain sane
33
- return []
35
+ return ()
34
36
parts = nodeid .split (SEP )
35
37
# Replace single last element 'test_foo.py::Bar' with multiple elements 'test_foo.py', 'Bar'
36
38
parts [- 1 :] = parts [- 1 ].split ("::" )
37
- return parts
39
+ # Convert parts into a tuple to avoid possible errors with caching of a mutable type
40
+ return tuple (parts )
38
41
39
42
40
43
def ischildnode (baseid , nodeid ):
You can’t perform that action at this time.
0 commit comments