@@ -68,6 +68,7 @@ def __init__(
68
68
self .source = source
69
69
self .line = line
70
70
self .column = column
71
+ self ._suite_marker = object ()
71
72
self ._test_marker = object ()
72
73
self ._local_marker = object ()
73
74
self ._global_marker = object ()
@@ -76,6 +77,12 @@ def __init__(
76
77
def id (self ) -> int :
77
78
return id (self )
78
79
80
+ def test_id (self ) -> int :
81
+ return id (self ._test_marker )
82
+
83
+ def suite_id (self ) -> int :
84
+ return id (self ._suite_marker )
85
+
79
86
def local_id (self ) -> int :
80
87
return id (self ._local_marker )
81
88
@@ -436,7 +443,8 @@ def get_scopes(self, frame_id: int) -> List[Scope]:
436
443
result : List [Scope ] = []
437
444
entry = next ((v for v in self .stack_frames if v .id == frame_id ), None )
438
445
if entry is not None :
439
- if entry .context () is not None :
446
+ context = entry .context ()
447
+ if context is not None :
440
448
result .append (
441
449
Scope (
442
450
name = "Local" ,
@@ -445,14 +453,33 @@ def get_scopes(self, frame_id: int) -> List[Scope]:
445
453
variables_reference = entry .local_id (),
446
454
)
447
455
)
448
- result .append (
449
- Scope (
450
- name = "Global" ,
451
- expensive = False ,
452
- presentation_hint = "global" ,
453
- variables_reference = entry .global_id (),
456
+ if context .variables ._test is not None and context .variables ._test != context .variables .current :
457
+ result .append (
458
+ Scope (
459
+ name = "Test" ,
460
+ expensive = False ,
461
+ presentation_hint = "test" ,
462
+ variables_reference = entry .test_id (),
463
+ )
464
+ )
465
+ if context .variables ._suite is not None and context .variables ._suite != context .variables .current :
466
+ result .append (
467
+ Scope (
468
+ name = "Suite" ,
469
+ expensive = False ,
470
+ presentation_hint = "suite" ,
471
+ variables_reference = entry .suite_id (),
472
+ )
473
+ )
474
+ if context .variables ._global is not None :
475
+ result .append (
476
+ Scope (
477
+ name = "Global" ,
478
+ expensive = False ,
479
+ presentation_hint = "global" ,
480
+ variables_reference = entry .global_id (),
481
+ )
454
482
)
455
- )
456
483
457
484
return result
458
485
@@ -465,16 +492,44 @@ def get_variables(
465
492
format : Optional [ValueFormat ] = None ,
466
493
) -> List [Variable ]:
467
494
result : List [Variable ] = []
468
- entry = next ((v for v in self .stack_frames if variables_reference in [v .global_id (), v .local_id ()]), None )
495
+ entry = next (
496
+ (
497
+ v
498
+ for v in self .stack_frames
499
+ if variables_reference in [v .global_id (), v .local_id (), v .suite_id (), v .test_id ()]
500
+ ),
501
+ None ,
502
+ )
469
503
if entry is not None :
470
504
context = entry .context ()
471
505
if context is not None :
472
- current_index = context .variables ._scopes .index (context .variables .current )
473
- globals = context .variables ._scopes [max (current_index - 1 , 0 )].as_dict ()
474
506
475
507
if entry .global_id () == variables_reference :
476
- result += [Variable (name = k , value = repr (v ), type = repr (type (v ))) for k , v in globals .items ()]
508
+ result += [
509
+ Variable (name = k , value = repr (v ), type = repr (type (v )))
510
+ for k , v in context .variables ._global .as_dict ().items ()
511
+ ]
512
+ elif entry .suite_id () == variables_reference :
513
+ # current_index = context.variables._scopes.index(context.variables._suite)
514
+ # globals = context.variables._scopes[max(current_index - 1, 0)].as_dict()
515
+ globals = context .variables ._global .as_dict ()
516
+ result += [
517
+ Variable (name = k , value = repr (v ), type = repr (type (v )))
518
+ for k , v in context .variables ._suite .as_dict ().items ()
519
+ if k not in globals or globals [k ] != v
520
+ ]
521
+ elif entry .test_id () == variables_reference :
522
+ # current_index = context.variables._scopes.index(context.variables._test)
523
+ # globals = context.variables._scopes[max(current_index - 1, 0)].as_dict()
524
+ globals = context .variables ._suite .as_dict ()
525
+ result += [
526
+ Variable (name = k , value = repr (v ), type = repr (type (v )))
527
+ for k , v in context .variables ._test .as_dict ().items ()
528
+ if k not in globals or globals [k ] != v
529
+ ]
477
530
elif entry .local_id () == variables_reference :
531
+ current_index = context .variables ._scopes .index (context .variables .current )
532
+ globals = context .variables ._scopes [max (current_index - 1 , 0 )].as_dict ()
478
533
result += [
479
534
Variable (name = k , value = repr (v ), type = repr (type (v )))
480
535
for k , v in context .variables .current .as_dict ().items ()
0 commit comments