File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
pythonFiles/testing_tools/adapter/pytest Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -434,6 +434,24 @@ def _parse_node_id(
434
434
)
435
435
436
436
437
+ def _find_left_bracket (nodeid ):
438
+ """Return tuple of path before test name, separator [, and test name.
439
+
440
+ If path looks like
441
+ 'dirname[sometext]/dirname/testfile.py::testset[testname]'
442
+ then partition returns the first left bracket - and extension crashes"""
443
+ bracketcount = 0
444
+ for index in range (len (nodeid ) - 1 , - 1 , - 1 ):
445
+ char = nodeid [index ]
446
+ if char == ']' :
447
+ bracketcount += 1
448
+ elif char == '[' :
449
+ bracketcount -= 1
450
+ if bracketcount == 0 :
451
+ return nodeid [:index ], nodeid [index ], nodeid [index + 1 :]
452
+ return nodeid , '' , ''
453
+
454
+
437
455
def _iter_nodes (
438
456
testid ,
439
457
kind ,
@@ -448,7 +466,7 @@ def _iter_nodes(
448
466
testid = "." + _pathsep + testid
449
467
450
468
if kind == "function" and nodeid .endswith ("]" ):
451
- funcid , sep , parameterized = nodeid . partition ( "[" )
469
+ funcid , sep , parameterized = _find_left_bracket ( nodeid )
452
470
if not sep :
453
471
raise should_never_reach_here (
454
472
nodeid ,
You can’t perform that action at this time.
0 commit comments