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

Commit

Permalink
Adding a test for raw unicode docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeezley committed Jun 22, 2015
1 parent 6039dc6 commit 98c230b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test_pep257.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from __future__ import with_statement

import sys
import os
import mock
import shutil
Expand Down Expand Up @@ -144,3 +145,27 @@ def foo():

out, err = env.invoke_pep257(args='--count')
assert '2' in out


def test_unicode_raw():
"""Test acceptance of unicode raw docstrings for python 2.x."""
if sys.version_info[0] >= 3:
return # ur"" is a syntax error in python 3.x

# This is all to avoid a syntax error for python 3.2
from codecs import unicode_escape_decode

def u(x):
return unicode_escape_decode(x)[0]

with Pep257Env() as env:
with env.open('example.py', 'wt') as example:
example.write(textwrap.dedent(u('''\
# -*- coding: utf-8 -*-
def foo():
ur"""Check unicode: \u2611 and raw: \\\\\\\\."""
''').encode('utf-8')))
env.write_config(ignore='D100', verbose=True)
out, err = env.invoke_pep257()
assert 'D301' not in err
assert 'D302' not in err

0 comments on commit 98c230b

Please sign in to comment.