From 39f6ea925e7e3e4c56e3a1ef2e988353ca731a4b Mon Sep 17 00:00:00 2001 From: Jitendra Yejare Date: Tue, 19 Dec 2023 17:06:14 +0530 Subject: [PATCH] regexed ignore list in marker Co-authored-by: Roman Plevka --- betelgeuse/parser.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/betelgeuse/parser.py b/betelgeuse/parser.py index 03e1058..840aff0 100644 --- a/betelgeuse/parser.py +++ b/betelgeuse/parser.py @@ -1,4 +1,5 @@ """Parsers for test docstrings.""" +import re from collections import namedtuple from io import StringIO from xml.dom import minidom @@ -200,14 +201,21 @@ def parse_markers(all_markers=None, config=None): resolved_markers = [] ignore_list = getattr(config, 'MARKERS_IGNORE_LIST', None) - def _process_marker(marker): - # Fetching exact marker name - marker_name = marker.split('mark.')[-1] + def _process_marker(_marker): + + marker_name = re.findall( + r'(?:pytest\.mark\.)?([^(\s()]+)(?=\s*\(|\s*$)', _marker) + if marker_name: + marker_name = marker_name[0] # ignoring the marker if in ignore list if ignore_list and any( - ignore_word in marker_name for ignore_word in ignore_list): + re.fullmatch( + ignore_word, marker_name + ) for ignore_word in ignore_list + ): return + resolved_markers.append(marker_name) for sec_marker in all_markers: