@@ -360,30 +360,29 @@ def __call__(self, *args: object, **kwargs: object):
360
360
return self .with_args (* args , ** kwargs )
361
361
362
362
363
- def get_unpacked_marks (obj ) -> List [Mark ]:
363
+ def get_unpacked_marks (obj : object ) -> Iterable [Mark ]:
364
364
"""Obtain the unpacked marks that are stored on an object."""
365
365
mark_list = getattr (obj , "pytestmark" , [])
366
366
if not isinstance (mark_list , list ):
367
367
mark_list = [mark_list ]
368
368
return normalize_mark_list (mark_list )
369
369
370
370
371
- def normalize_mark_list (mark_list : Iterable [Union [Mark , MarkDecorator ]]) -> List [Mark ]:
371
+ def normalize_mark_list (
372
+ mark_list : Iterable [Union [Mark , MarkDecorator ]]
373
+ ) -> Iterable [Mark ]:
372
374
"""
373
375
Normalize an iterable of Mark or MarkDecorator objects into a list of marks
374
376
by retrieving the `mark` attribute on MarkDecorator instances.
375
377
376
378
:param mark_list: marks to normalize
377
379
:returns: A new list of the extracted Mark objects
378
380
"""
379
-
380
- def parse_mark (mark : Union [Mark , MarkDecorator ]) -> Mark :
381
+ for mark in mark_list :
381
382
mark_obj = getattr (mark , "mark" , mark )
382
383
if not isinstance (mark_obj , Mark ):
383
384
raise TypeError (f"got { repr (mark_obj )} instead of Mark" )
384
- return mark_obj
385
-
386
- return [parse_mark (x ) for x in mark_list ]
385
+ yield mark_obj
387
386
388
387
389
388
def store_mark (obj , mark : Mark ) -> None :
@@ -394,7 +393,7 @@ def store_mark(obj, mark: Mark) -> None:
394
393
assert isinstance (mark , Mark ), mark
395
394
# Always reassign name to avoid updating pytestmark in a reference that
396
395
# was only borrowed.
397
- obj .pytestmark = get_unpacked_marks (obj ) + [ mark ]
396
+ obj .pytestmark = [ * get_unpacked_marks (obj ), mark ]
398
397
399
398
400
399
# Typing for builtin pytest marks. This is cheating; it gives builtin marks
0 commit comments