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

Method test_allow_bytes

testing/test_doctest.py:876–912  ·  view source on GitHub ↗

Test that doctests which output bytes work in all python versions tested by pytest when the ALLOW_BYTES option is used (either in the ini file or by an inline comment)(#1287).

(self, pytester, config_mode)

Source from the content-addressed store, hash-verified

874
875 @pytest.mark.parametrize("config_mode", ["ini", "comment"])
876 def test_allow_bytes(self, pytester, config_mode):
877 """Test that doctests which output bytes work in all python versions
878 tested by pytest when the ALLOW_BYTES option is used (either in
879 the ini file or by an inline comment)(#1287).
880 """
881 if config_mode == "ini":
882 pytester.makeini(
883 """
884 [pytest]
885 doctest_optionflags = ALLOW_BYTES
886 """
887 )
888 comment = ""
889 else:
890 comment = "#doctest: +ALLOW_BYTES"
891
892 pytester.maketxtfile(
893 test_doc="""
894 >>> b'foo' {comment}
895 'foo'
896 """.format(
897 comment=comment
898 )
899 )
900 pytester.makepyfile(
901 foo="""
902 def foo():
903 '''
904 >>> b'foo' {comment}
905 'foo'
906 '''
907 """.format(
908 comment=comment
909 )
910 )
911 reprec = pytester.inline_run("--doctest-modules")
912 reprec.assertoutcome(passed=2)
913
914 def test_unicode_string(self, pytester: Pytester):
915 """Test that doctests which output unicode fail in Python 2 when

Callers

nothing calls this directly

Calls 6

assertoutcomeMethod · 0.80
makeiniMethod · 0.45
maketxtfileMethod · 0.45
formatMethod · 0.45
makepyfileMethod · 0.45
inline_runMethod · 0.45

Tested by

no test coverage detected