/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/EncodingAdapter.py

  • Committer: Robert Collins
  • Date: 2005-10-16 22:31:25 UTC
  • mto: This revision was merged to the branch mainline in revision 1458.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051016223125-26d4401cb94b7b82
Branch.relpath has been moved to WorkingTree.relpath.

WorkingTree no no longer takes an inventory, rather it takes an optional branch
parameter, and if None is given will open the branch at basedir implicitly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
2
 
# -*- coding: utf-8 -*-
3
 
#
4
 
# This program is free software; you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation; either version 2 of the License, or
7
 
# (at your option) any later version.
8
 
#
9
 
# This program is distributed in the hope that it will be useful,
10
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
# GNU General Public License for more details.
13
 
#
14
 
# You should have received a copy of the GNU General Public License
15
 
# along with this program; if not, write to the Free Software
16
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
 
 
18
 
"""Adapter for running test cases against multiple encodings."""
19
 
 
20
 
from copy import deepcopy
21
 
 
22
 
from bzrlib.tests import TestSuite
23
 
 
24
 
 
25
 
# prefix for micro (1/1000000)
26
 
_mu = u'\xb5'
27
 
 
28
 
# greek letter omega, not to be confused with
29
 
# the Ohm sign, u'\u2126'. Though they are probably identical
30
 
# cp437 can handle the first, but not the second
31
 
_omega = u'\u03a9'
32
 
 
33
 
# smallest error possible, epsilon
34
 
# cp437 handles u03b5, but not u2208 the 'element of' operator
35
 
_epsilon = u'\u03b5'
36
 
 
37
 
# Swedish?
38
 
_erik = u'Erik B\xe5gfors'
39
 
 
40
 
# Swedish 'räksmörgås' means shrimp sandwich
41
 
_shrimp_sandwich = u'r\xe4ksm\xf6rg\xe5s'
42
 
 
43
 
# Arabic, probably only Unicode encodings can handle this one
44
 
_juju = u'\u062c\u0648\u062c\u0648'
45
 
 
46
 
# iso-8859-1 alternative for juju
47
 
_juju_alt = u'j\xfbj\xfa'
48
 
 
49
 
# Russian, 'Alexander' in russian
50
 
_alexander = u'\u0410\u043b\u0435\u043a\u0441\u0430\u043d\u0434\u0440'
51
 
# The word 'test' in Russian
52
 
_russian_test = u'\u0422\u0435\u0441\u0442'
53
 
 
54
 
# Kanji
55
 
# It is a kanji sequence for nihonjin, or Japanese in English.
56
 
#
57
 
# '\u4eba' being person, 'u\65e5' sun and '\u672c' origin. Ie,
58
 
# sun-origin-person, 'native from the land where the sun rises'. Note, I'm
59
 
# not a fluent speaker, so this is just my crude breakdown.
60
 
#
61
 
# Wouter van Heyst
62
 
_nihonjin = u'\u65e5\u672c\u4eba'
63
 
 
64
 
# Czech
65
 
# It's what is usually used for showing how fonts look, because it contains
66
 
# most accented characters, ie. in places where Englishman use 'Quick brown fox
67
 
# jumped over a lazy dog'. The literal translation of the Czech version would
68
 
# be something like 'Yellow horse groaned devilish codes'. Actually originally
69
 
# the last word used to be 'ódy' (odes). The 'k' was added as a pun when using
70
 
# the sentece to check whether one has properly set encoding.
71
 
_yellow_horse = (u'\u017dlu\u0165ou\u010dk\xfd k\u016f\u0148'
72
 
                 u' \xfap\u011bl \u010f\xe1belsk\xe9 k\xf3dy')
73
 
_yellow = u'\u017dlu\u0165ou\u010dk\xfd'
74
 
_someone = u'Some\u016f\u0148\u011b'
75
 
_something = u'\u0165ou\u010dk\xfd'
76
 
 
77
 
# Hebrew
78
 
# Shalom -> 'hello' or 'peace', used as a common greeting
79
 
_shalom = u'\u05e9\u05dc\u05d5\u05dd'
80
 
 
81
 
 
82
 
encoding_scenarios = [
83
 
        # Permutation 1 of utf-8
84
 
        ('utf-8,1', {
85
 
            'info': {
86
 
                'committer': _erik,
87
 
                'message': _yellow_horse,
88
 
                'filename': _shrimp_sandwich,
89
 
                'directory': _nihonjin,
90
 
                },
91
 
            'encoding': 'utf-8',
92
 
            }),
93
 
        # Permutation 2 of utf-8
94
 
        ('utf-8,2', {
95
 
            'info': {
96
 
                'committer': _alexander,
97
 
                'message': u'Testing ' + _mu,
98
 
                'filename': _shalom,
99
 
                'directory': _juju,
100
 
                },
101
 
            'encoding': 'utf-8',
102
 
            }),
103
 
        ('iso-8859-1', {
104
 
            'info': {
105
 
                'committer': _erik,
106
 
                'message': u'Testing ' + _mu,
107
 
                'filename': _juju_alt,
108
 
                'directory': _shrimp_sandwich,
109
 
                },
110
 
            'encoding': 'iso-8859-1',
111
 
            }),
112
 
        ('iso-8859-2', {
113
 
            'info': {
114
 
                'committer': _someone,
115
 
                'message': _yellow_horse,
116
 
                'filename': _yellow,
117
 
                'directory': _something,
118
 
                },
119
 
            'encoding': 'iso-8859-2',
120
 
            }),
121
 
        ('cp1251', {
122
 
            'info': {
123
 
                'committer': _alexander,
124
 
                'message': u'Testing ' + _mu,
125
 
                'filename': _russian_test,
126
 
                'directory': _russian_test + 'dir',
127
 
                },
128
 
            'encoding': 'cp1251',
129
 
            }),
130
 
# The iso-8859-1 tests run on a default windows cp437 installation
131
 
# and it takes a long time to run an extra permutation of the tests
132
 
# But just in case we want to add this back in:
133
 
#        ('cp437', {'committer':_erik
134
 
#                  , 'message':u'Testing ' + _mu
135
 
#                  , 'filename':'file_' + _omega
136
 
#                  , 'directory':_epsilon + '_dir',
137
 
#            'encoding': 'cp437'}),
138
 
    ]