~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/EncodingAdapter.py

  • Committer: John Arbash Meinel
  • Date: 2006-01-13 06:04:00 UTC
  • mto: (1685.1.1 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060113060400-e24615f222244238
Hooked up EncodingAdapter, and updated test_non_ascii.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
    Each copy is also given a new id() to make it easy to identify.
72
72
    """
73
73
 
 
74
    _encodings = [
 
75
        # Permutation 1 of utf-8
 
76
        ('utf-8', {'committer':_erik
 
77
                  , 'message':_yellow_horse
 
78
                  , 'filename':_shrimp_sandwich
 
79
                  , 'directory':_nihonjin}),
 
80
        # Permutation 2 of utf-8
 
81
        ('utf-8', {'committer':_alexander
 
82
                  , 'message':u'Testing ' + _mu
 
83
                  , 'filename':_juju
 
84
                  , 'directory':_juju_alt}),
 
85
        ('iso-8859-1', {'committer':_erik
 
86
                  , 'message':u'Testing ' + _mu
 
87
                  , 'filename':_juju_alt
 
88
                  , 'directory':_shrimp_sandwich}),
 
89
        ('iso-8859-2', {'committer':'TODO-iso8859-2-committer'
 
90
                  , 'message':_yellow_horse
 
91
                  , 'filename':'TODO-iso8859-2-filename'
 
92
                  , 'directory':'TODO-iso8859-2-dir'}),
 
93
        ('cp1251', {'committer':_alexander
 
94
                  , 'message':u'Testing ' + _mu
 
95
                  , 'filename':'TODO-cp1251-filename'
 
96
                  , 'directory':'TODO-cp1251-dir'}),
 
97
    ]
 
98
 
74
99
    def adapt(self, test):
75
100
        result = TestSuite()
76
 
        for encoding, info in self._test_permutations():
 
101
        for encoding, info in self._encodings:
77
102
            new_test = deepcopy(test)
78
103
            new_test.encoding = encoding
79
104
            new_test.info = info
80
 
            def new_test_id():
81
 
                return '%s(%s)' % (new_test.id(), encoding)
82
 
            new_test.id = new_test_id
 
105
            def make_new_test_id():
 
106
                new_id = "%s(%s)" % (new_test.id(), encoding)
 
107
                return lambda: new_id
 
108
            new_test.id = make_new_test_id()
83
109
            result.addTest(new_test)
84
110
        return result
85
111
 
86
 
    def _test_permutations(self):
87
 
        """Return a list of encoding/info pairs to test.
88
 
 
89
 
        encoding should be a string such as 'utf-8'
90
 
        info is a dictionary containing 'committer', 'filename', 'message',
91
 
             'directory'
92
 
        """
93
 
        return [
94
 
            # Permutation 1 of utf-8
95
 
            ('utf-8', {'committer':_erik
96
 
                      , 'message':_yellow_horse
97
 
                      , 'filename':_shrimp_sandwich
98
 
                      , 'directory':_nihonjin}),
99
 
            # Permutation 2 of utf-8
100
 
            ('utf-8', {'committer':_alexander
101
 
                      , 'message':u'Testing ' + _mu
102
 
                      , 'filename':_juju,
103
 
                      , 'directory':_juju_alt}),
104
 
            ('iso-8859-1', {'committer':_erik
105
 
                      , 'message':u'Testing ' + _mu
106
 
                      , 'filename':_juju_alt
107
 
                      , 'directory':_shrimp_sandwich}),
108
 
            ('iso-8859-2', {'committer':'TODO-iso8859-2-committer'
109
 
                      , 'message':_yellow_horse
110
 
                      , 'filename':'TODO-iso8859-2-filename'
111
 
                      , 'directory':'TODO-iso8859-2-dir'}),
112
 
            ('cp1251', {'committer':_alexander
113
 
                      , 'message':u'Testing ' + _mu
114
 
                      , 'filename':'TODO-cp1251-filename'
115
 
                      , 'directory':'TODO-cp1251-dir'}),
116
 
        ]
117
 
 
118
 
 
119
112