def _get_checker():
if hasattr(_get_checker, "<STR_LIT>"):<EOL><INDENT>return _get_checker.LiteralsOutputChecker()<EOL><DEDENT>import doctest<EOL>import re<EOL>class LiteralsOutputChecker(doctest.OutputChecker):<EOL><INDENT>"""<STR_LIT>"""<EOL>_unicode_literal_re = re.compile(r"<STR_LIT>", re.UNICODE)<EOL>_bytes_literal_re = re.compile(r"<STR_LIT>", re.UNICODE)<EOL>def check_output(self, want, got, optionflags):<EOL><INDENT>res = doctest.OutputChecker.check_output(self, want, got, optionflags)<EOL>if res:<EOL><INDENT>return True<EOL><DEDENT>allow_unicode = optionflags & _get_allow_unicode_flag()<EOL>allow_bytes = optionflags & _get_allow_bytes_flag()<EOL>if not allow_unicode and not allow_bytes:<EOL><INDENT>return False<EOL><DEDENT>else:  <EOL><INDENT>def remove_prefixes(regex, txt):<EOL><INDENT>return re.sub(regex, r"<STR_LIT>", txt)<EOL><DEDENT>if allow_unicode:<EOL><INDENT>want = remove_prefixes(self._unicode_literal_re, want)<EOL>got = remove_prefixes(self._unicode_literal_re, got)<EOL><DEDENT>if allow_bytes:<EOL><INDENT>want = remove_prefixes(self._bytes_literal_re, want)<EOL>got = remove_prefixes(self._bytes_literal_re, got)<EOL><DEDENT>res = doctest.OutputChecker.check_output(self, want, got, optionflags)<EOL>return res<EOL><DEDENT><DEDENT><DEDENT>_get_checker.LiteralsOutputChecker = LiteralsOutputChecker<EOL>return _get_checker.LiteralsOutputChecker()<EOL>
Returns a doctest.OutputChecker subclass that takes in account the
ALLOW_UNICODE option to ignore u'' prefixes in strings and ALLOW_BYTES
to strip b'' prefixes.
Useful when the same doctest should run in Python 2 and Python 3.

An inner class is used to avoid importing "doctest" at the module
level.