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)
| 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 |
nothing calls this directly
no test coverage detected