review/tests/test_encoding.py @ fc97fabaf28d
Update windows contrib script for current TortoiseHg version (2.6.2).
TortoiseHg 2.6.2 is packaged with Python 2.7.3 (and not 2.6.x), and now
includes some of the libraries that this script previously needed to copy into
place.
author |
Chris Nielsen |
date |
Fri, 18 Jan 2013 11:51:36 -0500 |
parents |
cada9aab8b6f |
children |
(none) |
# coding=utf-8
#
import os
import unicodedata
from nose import with_setup
from util import setup_reviewed_sandbox, teardown_sandbox, review, should_fail_with
from util import get_datastore_repo, get_sandbox_repo, get_ui
from util import check_comment_exists_on_line
from .. import api, messages, rutil
from mercurial.node import hex
@with_setup(setup_reviewed_sandbox(), teardown_sandbox)
def test_comment_encoding():
review(comment=True, message=rutil.tolocal(u'Téstíng.'))
output = review()
assert messages.REVIEW_LOG_COMMENT_LINE % rutil.tolocal(u'Téstíng.') in output
@with_setup(setup_reviewed_sandbox(), teardown_sandbox)
def test_signoff_encoding():
review(signoff=True, message=rutil.tolocal(u'Téstíng.'))
output = review()
assert messages.REVIEW_LOG_SIGNOFF_LINE % rutil.tolocal(u'Téstíng.') in output
@with_setup(setup_reviewed_sandbox(username=u'Tést <tést@test.com>', encoding='UTF-8'), teardown_sandbox)
def test_username_encoding_utf8():
review(comment=True, message=rutil.tolocal(u'Cómment.'))
output = review()
assert u'Tést'.encode('UTF-8') in output
assert u'Cómment.'.encode('UTF-8') in output
@with_setup(setup_reviewed_sandbox(username=u'Tést <tést@test.com>', encoding='ISO-8859-1'), teardown_sandbox)
def test_username_encoding_iso_8859_1():
review(comment=True, message=rutil.tolocal(u'Cómment.'))
output = review()
assert u'Tést'.encode('ISO-8859-1') in output
assert u'Cómment.'.encode('ISO-8859-1') in output
@with_setup(setup_reviewed_sandbox(username=u'Tést <tést@test.com>', encoding='UTF-8', file_encoding='UTF-8'), teardown_sandbox)
def test_file_encoding_utf8():
review(comment=True, message=rutil.tolocal(u'Cómment.'), rev='1')
output = review(rev='1')
normal_output = unicodedata.normalize('NFC', output.decode('UTF-8'))
assert unicodedata.normalize('NFC', u'filé') in normal_output
assert u'Tést'.encode('UTF-8') in output
assert u'Cómment.'.encode('UTF-8') in output
assert u'-oné'.encode('UTF-8') in output
assert u'+óne'.encode('UTF-8') in output
assert u'-twó'.encode('UTF-8') in output
assert u'+two'.encode('UTF-8') in output
assert u'-thrée'.encode('UTF-8') in output
assert u'+threé'.encode('UTF-8') in output
@with_setup(setup_reviewed_sandbox(username=u'Tést <tést@test.com>', encoding='latin-1', file_encoding='latin-1'), teardown_sandbox)
def test_file_encoding_iso88591():
review(comment=True, message=rutil.tolocal(u'Cómment.'), rev='1')
output = review(rev='1')
# TODO: Make this work.
#normal_output = unicodedata.normalize('NFC', output.decode('latin-1'))
#assert unicodedata.normalize('NFC', u'filé') in normal_output
assert u'Tést'.encode('latin-1') in output
assert u'Cómment.'.encode('latin-1') in output
assert u'-oné'.encode('latin-1') in output
assert u'+óne'.encode('latin-1') in output
assert u'-twó'.encode('latin-1') in output
assert u'+two'.encode('latin-1') in output
assert u'-thrée'.encode('latin-1') in output
assert u'+threé'.encode('latin-1') in output