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