@@ -21,6 +21,32 @@ def timestamp():
2121    return  str (int (time () *  1000 ))
2222
2323
24+ def  trim_docstring (docstring ):
25+     if  not  docstring :
26+         return  '' 
27+     # Convert tabs to spaces (following the normal Python rules) 
28+     # and split into a list of lines: 
29+     lines  =  docstring .expandtabs ().splitlines ()
30+     # Determine minimum indentation (first line doesn't count): 
31+     indent  =  sys .maxsize 
32+     for  line  in  lines [1 :]:
33+         stripped  =  line .lstrip ()
34+         if  stripped :
35+             indent  =  min (indent , len (line ) -  len (stripped ))
36+     # Remove indentation (first line is special): 
37+     trimmed  =  [lines [0 ].strip ()]
38+     if  indent  <  sys .maxsize :
39+         for  line  in  lines [1 :]:
40+             trimmed .append (line [indent :].rstrip ())
41+     # Strip off trailing and leading blank lines: 
42+     while  trimmed  and  not  trimmed [- 1 ]:
43+         trimmed .pop ()
44+     while  trimmed  and  not  trimmed [0 ]:
45+         trimmed .pop (0 )
46+     # Return a single string: 
47+     return  '\n ' .join (trimmed )
48+ 
49+ 
2450class  Singleton (type ):
2551    _instances  =  {}
2652
@@ -385,8 +411,13 @@ def _get_item_dirs(item):
385411    def  _get_item_tags (self , item ):
386412        # Try to extract names of @pytest.mark.* decorators used for test item 
387413        # and exclude those which present in rp_ignore_tags parameter 
388-         return  [k  for  k  in  item .keywords  if  item .get_marker (k ) is  not   None 
414+         #return [k for k in item.keywords if item.get_marker(k) is not None 
415+         #        and k not in self.ignored_tags] 
416+         tags  =  [k  for  k  in  item .keywords  if  item .get_marker (k ) is  not   None 
389417                and  k  not  in   self .ignored_tags ]
418+         tags .extend (item .session .config .getini ('rp_tests_tags' ))
419+ 
420+         return  tags 
390421
391422    def  _get_parameters (self , item ):
392423        return  item .callspec .params  if  hasattr (item , 'callspec' ) else  {}
@@ -408,6 +439,6 @@ def _get_item_description(test_item):
408439        if  isinstance (test_item , (Class , Function , Module , Item )):
409440            doc  =  test_item .obj .__doc__ 
410441            if  doc  is  not   None :
411-                 return  doc . strip ( )
442+                 return  trim_docstring ( doc )
412443        if  isinstance (test_item , DoctestItem ):
413444            return  test_item .reportinfo ()[2 ]
0 commit comments