@@ -520,39 +520,48 @@ def get_alternative_id(self):
520520 return mini_idvalset (self .argnames , argval , idx = self .alternative_index )
521521
522522
523- if PYTEST54_OR_GREATER :
524- # an empty string will be taken into account but NOT filtered out in CallSpec2.id.
525- # so instead we create a dedicated unique string and return it.
526- # Ugly but the only viable alternative seems worse: it would be to return an empty string
527- # and in `remove_empty_ids` to always remove all empty strings (not necessary the ones set by us).
528- # That is too much of a change.
523+ # if PYTEST54_OR_GREATER:
524+ # # an empty string will be taken into account but NOT filtered out in CallSpec2.id.
525+ # # so instead we create a dedicated unique string and return it.
526+ # # Ugly but the only viable alternative seems worse: it would be to return an empty string
527+ # # and in `remove_empty_ids` to always remove all empty strings (not necessary the ones set by us).
528+ # # That is too much of a change.
529529
530- EMPTY_ID = "13h#987__36a721f8Z44526!8*72 "
530+ EMPTY_ID = "<pytest_cases_empty_id> "
531531
532+
533+ if has_pytest_param :
532534 def remove_empty_ids (callspec ):
533535 # used by plugin.py to remove the EMPTY_ID from the callspecs
534536 callspec ._idlist = [c for c in callspec ._idlist if not c .startswith (EMPTY_ID )]
535-
536- elif PYTEST421_OR_GREATER :
537- # an empty string will be taken into account and filtered out in CallSpec2.id.
538- EMPTY_ID = ""
539-
540537else :
541- # an empty string will only be taken into account if its truth value is True
542- # it will be filtered out in CallSpec2.id
543- class EmptyId (str ):
544- def __new__ (cls ):
545- return str .__new__ (cls , "" )
546-
547- def __nonzero__ (self ):
548- # python 2
549- return True
538+ def remove_empty_ids (callspec ):
539+ # used by plugin.py to remove the EMPTY_ID from the callspecs
540+ callspec ._idlist = [c for c in callspec ._idlist if not c .endswith (EMPTY_ID )]
550541
551- def __bool__ (self ):
552- # python 3
553- return True
554542
555- EMPTY_ID = EmptyId ()
543+ # elif PYTEST421_OR_GREATER:
544+ # # an empty string will be taken into account and filtered out in CallSpec2.id.
545+ # # but.... if this empty string appears several times in the tests it is appended with a number to become unique :(
546+ # EMPTY_ID = ""
547+ #
548+ # else:
549+ # # an empty string will only be taken into account if its truth value is True
550+ # # but.... if this empty string appears several times in the tests it is appended with a number to become unique :(
551+ # # it will be filtered out in CallSpec2.id
552+ # class EmptyId(str):
553+ # def __new__(cls):
554+ # return str.__new__(cls, "")
555+ #
556+ # def __nonzero__(self):
557+ # # python 2
558+ # return True
559+ #
560+ # def __bool__(self):
561+ # # python 3
562+ # return True
563+ #
564+ # EMPTY_ID = EmptyId()
556565
557566
558567class ParamIdMakers (UnionIdMakers ):
0 commit comments