MCPcopy
hub / github.com/pytest-dev/pytest / check_output

Method check_output

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

Source from the content-addressed store, hash-verified

606 )
607
608 def check_output(self, want: str, got: str, optionflags: int) -> bool:
609 if super().check_output(want, got, optionflags):
610 return True
611
612 allow_unicode = optionflags & _get_allow_unicode_flag()
613 allow_bytes = optionflags & _get_allow_bytes_flag()
614 allow_number = optionflags & _get_number_flag()
615
616 if not allow_unicode and not allow_bytes and not allow_number:
617 return False
618
619 def remove_prefixes(regex: re.Pattern[str], txt: str) -> str:
620 return re.sub(regex, r"\1\2", txt)
621
622 if allow_unicode:
623 want = remove_prefixes(self._unicode_literal_re, want)
624 got = remove_prefixes(self._unicode_literal_re, got)
625
626 if allow_bytes:
627 want = remove_prefixes(self._bytes_literal_re, want)
628 got = remove_prefixes(self._bytes_literal_re, got)
629
630 if allow_number:
631 got = self._remove_unwanted_precision(want, got)
632
633 return super().check_output(want, got, optionflags)
634
635 def _remove_unwanted_precision(self, want: str, got: str) -> str:
636 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