[ADD] test: added smoke test for tools.translate.quote and unquote
bzr revid: odo@openerp.com-20101116124328-1ez3w3jxvf5v3ilt
This commit is contained in:
parent
6a3324a7a0
commit
0c489cf1fa
|
@ -20,3 +20,4 @@
|
|||
##############################################################################
|
||||
|
||||
from test_osv import *
|
||||
from test_translate import *
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2010 OpenERP S.A. http://www.openerp.com
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import unittest
|
||||
from tools.translate import quote, unquote
|
||||
|
||||
class TranslationToolsTestCase(unittest.TestCase):
|
||||
|
||||
def test_quote_unquote(self):
|
||||
|
||||
def test_string(str):
|
||||
quoted = quote(str)
|
||||
#print "\n1:", repr(str)
|
||||
#print "2:", repr(quoted)
|
||||
unquoted = unquote("".join(quoted.split('"\n"')))
|
||||
#print "3:", repr(unquoted)
|
||||
self.assertEquals(str, unquoted)
|
||||
|
||||
test_string("""test \nall kinds\n \n o\r
|
||||
\\\\ nope\n\n"
|
||||
""")
|
||||
|
||||
# The ones with 1+ backslashes directly followed by
|
||||
# a newline or literal N can fail... we would need a
|
||||
# state-machine parser to handle these, but this would
|
||||
# be much slower so it's better to avoid them at the moment
|
||||
self.assertRaises(AssertionError, quote, """test \nall kinds\n\no\r
|
||||
\\\\nope\n\n"
|
||||
""")
|
||||
|
Loading…
Reference in New Issue