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

Method test_allow_unicode

testing/test_doctest.py:837–873  ·  view source on GitHub ↗

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

(self, pytester, config_mode)

Source from the content-addressed store, hash-verified

835class TestLiterals:
836 @pytest.mark.parametrize("config_mode", ["ini", "comment"])
837 def test_allow_unicode(self, pytester, config_mode):
838 """Test that doctests which output unicode work in all python versions
839 tested by pytest when the ALLOW_UNICODE option is used (either in
840 the ini file or by an inline comment).
841 """
842 if config_mode == "ini":
843 pytester.makeini(
844 """
845 [pytest]
846 doctest_optionflags = ALLOW_UNICODE
847 """
848 )
849 comment = ""
850 else:
851 comment = "#doctest: +ALLOW_UNICODE"
852
853 pytester.maketxtfile(
854 test_doc="""
855 >>> b'12'.decode('ascii') {comment}
856 '12'
857 """.format(
858 comment=comment
859 )
860 )
861 pytester.makepyfile(
862 foo="""
863 def foo():
864 '''
865 >>> b'12'.decode('ascii') {comment}
866 '12'
867 '''
868 """.format(
869 comment=comment
870 )
871 )
872 reprec = pytester.inline_run("--doctest-modules")
873 reprec.assertoutcome(passed=2)
874
875 @pytest.mark.parametrize("config_mode", ["ini", "comment"])
876 def test_allow_bytes(self, pytester, config_mode):

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