Utilize more_itertools to consolidate logic when collecting marks.
This commit is contained in:
parent
b77d0deaf5
commit
cfebbfc114
|
@ -45,6 +45,7 @@ packages =
|
||||||
py_modules = py
|
py_modules = py
|
||||||
install_requires =
|
install_requires =
|
||||||
iniconfig
|
iniconfig
|
||||||
|
more-itertools
|
||||||
packaging
|
packaging
|
||||||
pluggy>=0.12,<2.0
|
pluggy>=0.12,<2.0
|
||||||
colorama;sys_platform=="win32"
|
colorama;sys_platform=="win32"
|
||||||
|
|
|
@ -22,6 +22,9 @@ from typing import TYPE_CHECKING
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
from more_itertools import always_iterable
|
||||||
|
from more_itertools import flatten
|
||||||
|
|
||||||
from .._code import getfslineno
|
from .._code import getfslineno
|
||||||
from ..compat import ascii_escaped
|
from ..compat import ascii_escaped
|
||||||
from ..compat import NOTSET
|
from ..compat import NOTSET
|
||||||
|
@ -375,18 +378,9 @@ def get_unpacked_marks(
|
||||||
mark_lists = [obj.__dict__.get("pytestmark", [])]
|
mark_lists = [obj.__dict__.get("pytestmark", [])]
|
||||||
else:
|
else:
|
||||||
mark_lists = [x.__dict__.get("pytestmark", []) for x in obj.__mro__]
|
mark_lists = [x.__dict__.get("pytestmark", []) for x in obj.__mro__]
|
||||||
mark_list = []
|
|
||||||
for item in mark_lists:
|
|
||||||
if isinstance(item, list):
|
|
||||||
mark_list.extend(item)
|
|
||||||
else:
|
|
||||||
mark_list.append(item)
|
|
||||||
else:
|
else:
|
||||||
mark_attribute = getattr(obj, "pytestmark", [])
|
mark_lists = [getattr(obj, "pytestmark", [])]
|
||||||
if isinstance(mark_attribute, list):
|
mark_list = flatten(map(always_iterable, mark_lists))
|
||||||
mark_list = mark_attribute
|
|
||||||
else:
|
|
||||||
mark_list = [mark_attribute]
|
|
||||||
return list(normalize_mark_list(mark_list))
|
return list(normalize_mark_list(mark_list))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue