MCPcopy Create free account
hub / github.com/pytest-dev/pytest / check_output

Method check_output

src/_pytest/doctest.py:618–643  ·  view source on GitHub ↗
(self, want: str, got: str, optionflags: int)

Source from the content-addressed store, hash-verified

616 )
617
618 def check_output(self, want: str, got: str, optionflags: int) -> bool:
619 if super().check_output(want, got, optionflags):
620 return True
621
622 allow_unicode = optionflags & _get_allow_unicode_flag()
623 allow_bytes = optionflags & _get_allow_bytes_flag()
624 allow_number = optionflags & _get_number_flag()
625
626 if not allow_unicode and not allow_bytes and not allow_number:
627 return False
628
629 def remove_prefixes(regex: Pattern[str], txt: str) -> str:
630 return re.sub(regex, r"\1\2", txt)
631
632 if allow_unicode:
633 want = remove_prefixes(self._unicode_literal_re, want)
634 got = remove_prefixes(self._unicode_literal_re, got)
635
636 if allow_bytes:
637 want = remove_prefixes(self._bytes_literal_re, want)
638 got = remove_prefixes(self._bytes_literal_re, got)
639
640 if allow_number:
641 got = self._remove_unwanted_precision(want, got)
642
643 return super().check_output(want, got, optionflags)
644
645 def _remove_unwanted_precision(self, want: str, got: str) -> str:
646 wants = list(self._number_re.finditer(want))

Callers 2

_wrapcallFunction · 0.80
lsof_checkFunction · 0.80

Calls 4

_get_allow_unicode_flagFunction · 0.85
_get_allow_bytes_flagFunction · 0.85
_get_number_flagFunction · 0.85

Tested by

no test coverage detected