Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 98c230b

Browse files
committed
Adding a test for raw unicode docstrings
1 parent 6039dc6 commit 98c230b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test_pep257.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from __future__ import with_statement
66

7+
import sys
78
import os
89
import mock
910
import shutil
@@ -144,3 +145,27 @@ def foo():
144145

145146
out, err = env.invoke_pep257(args='--count')
146147
assert '2' in out
148+
149+
150+
def test_unicode_raw():
151+
"""Test acceptance of unicode raw docstrings for python 2.x."""
152+
if sys.version_info[0] >= 3:
153+
return # ur"" is a syntax error in python 3.x
154+
155+
# This is all to avoid a syntax error for python 3.2
156+
from codecs import unicode_escape_decode
157+
158+
def u(x):
159+
return unicode_escape_decode(x)[0]
160+
161+
with Pep257Env() as env:
162+
with env.open('example.py', 'wt') as example:
163+
example.write(textwrap.dedent(u('''\
164+
# -*- coding: utf-8 -*-
165+
def foo():
166+
ur"""Check unicode: \u2611 and raw: \\\\\\\\."""
167+
''').encode('utf-8')))
168+
env.write_config(ignore='D100', verbose=True)
169+
out, err = env.invoke_pep257()
170+
assert 'D301' not in err
171+
assert 'D302' not in err

0 commit comments

Comments
 (0)