summaryrefslogtreecommitdiff
path: root/testing/test_doctest.py
diff options
context:
space:
mode:
authorManuel Krebber <manuel.krebber@granikos.eu>2016-11-29 12:18:41 +0100
committerManuel Krebber <manuel.krebber@granikos.eu>2016-11-29 12:29:16 +0100
commitd254c6b0aeb872a791889d5e3497fa3ca679c482 (patch)
treeb91d89337903d252c0ef06780147cbdd76ae5187 /testing/test_doctest.py
parented977513ec6af2e9015e6f6eee6e6b2a0b48e2c5 (diff)
downloadpytest-d254c6b0aeb872a791889d5e3497fa3ca679c482.tar.gz
Added some tests for --docstring-encoding option. Added option to specify encoding for internal testdir._makefile() for the tests.
Diffstat (limited to 'testing/test_doctest.py')
-rw-r--r--testing/test_doctest.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/test_doctest.py b/testing/test_doctest.py
index 4ea2cc58e..4ecd5744b 100644
--- a/testing/test_doctest.py
+++ b/testing/test_doctest.py
@@ -129,6 +129,52 @@ class TestDoctests:
'*1 passed*',
])
+ def test_encoding_ascii(self, testdir):
+ """Test support for --doctest-encoding option.
+ """
+ testdir._makefile(".txt", ["""
+ >>> 1
+ 1
+ """], {}, encoding='ascii')
+
+ result = testdir.runpytest("--doctest-encoding=ascii")
+
+ result.stdout.fnmatch_lines([
+ '*1 passed*',
+ ])
+
+ def test_encoding_latin1(self, testdir):
+ """Test support for --doctest-encoding option.
+ """
+ testdir._makefile(".txt", ["""
+ >>> 'üäö'
+ 'üäö'
+ """], {}, encoding='latin1')
+
+ result = testdir.runpytest("--doctest-encoding=latin1")
+
+ result.stdout.fnmatch_lines([
+ '*1 passed*',
+ ])
+
+ def test_encoding_utf8(self, testdir):
+ """Test support for --doctest-encoding option.
+ """
+ testdir.maketxtfile("""
+ >>> 'üäö'
+ 'üäö'
+ """)
+
+ result = testdir.runpytest()
+ result.stdout.fnmatch_lines([
+ '*1 passed*',
+ ])
+
+ result = testdir.runpytest("--doctest-encoding=utf-8")
+ result.stdout.fnmatch_lines([
+ '*1 passed*',
+ ])
+
def test_doctest_unexpected_exception(self, testdir):
testdir.maketxtfile("""
>>> i = 0