~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_conflicts.py

  • Committer: Jelmer Vernooij
  • Date: 2011-05-16 13:39:39 UTC
  • mto: (5923.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 5925.
  • Revision ID: jelmer@samba.org-20110516133939-8u1pc9utas3uw1lt
Require a unicode prompt to be passed into all methods that prompt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
])
63
63
 
64
64
 
65
 
def vary_by_conflicts():
66
 
    for conflict in example_conflicts:
67
 
        yield (conflict.__class__.__name__, {"conflict": conflict})
68
 
 
69
 
 
70
65
class TestConflicts(tests.TestCaseWithTransport):
71
66
 
72
67
    def test_resolve_conflict_dir(self):
125
120
        self.assertEqual(conflicts.ConflictList([]), tree.conflicts())
126
121
 
127
122
 
128
 
class TestPerConflict(tests.TestCase):
129
 
 
130
 
    scenarios = scenarios.multiply_scenarios(vary_by_conflicts())
131
 
 
132
 
    def test_stringification(self):
133
 
        text = unicode(self.conflict)
134
 
        self.assertContainsString(text, self.conflict.path)
135
 
        self.assertContainsString(text.lower(), "conflict")
136
 
        self.assertContainsString(repr(self.conflict),
137
 
            self.conflict.__class__.__name__)
 
123
class TestConflictStanzas(tests.TestCase):
138
124
 
139
125
    def test_stanza_roundtrip(self):
140
 
        p = self.conflict
141
 
        o = conflicts.Conflict.factory(**p.as_stanza().as_dict())
142
 
        self.assertEqual(o, p)
143
 
 
144
 
        self.assertIsInstance(o.path, unicode)
145
 
 
146
 
        if o.file_id is not None:
147
 
            self.assertIsInstance(o.file_id, str)
148
 
 
149
 
        conflict_path = getattr(o, 'conflict_path', None)
150
 
        if conflict_path is not None:
151
 
            self.assertIsInstance(conflict_path, unicode)
152
 
 
153
 
        conflict_file_id = getattr(o, 'conflict_file_id', None)
154
 
        if conflict_file_id is not None:
155
 
            self.assertIsInstance(conflict_file_id, str)
 
126
        # write and read our example stanza.
 
127
        stanza_iter = example_conflicts.to_stanzas()
 
128
        processed = conflicts.ConflictList.from_stanzas(stanza_iter)
 
129
        for o, p in zip(processed, example_conflicts):
 
130
            self.assertEqual(o, p)
 
131
 
 
132
            self.assertIsInstance(o.path, unicode)
 
133
 
 
134
            if o.file_id is not None:
 
135
                self.assertIsInstance(o.file_id, str)
 
136
 
 
137
            conflict_path = getattr(o, 'conflict_path', None)
 
138
            if conflict_path is not None:
 
139
                self.assertIsInstance(conflict_path, unicode)
 
140
 
 
141
            conflict_file_id = getattr(o, 'conflict_file_id', None)
 
142
            if conflict_file_id is not None:
 
143
                self.assertIsInstance(conflict_file_id, str)
156
144
 
157
145
    def test_stanzification(self):
158
 
        stanza = self.conflict.as_stanza()
159
 
        if 'file_id' in stanza:
160
 
            # In Stanza form, the file_id has to be unicode.
161
 
            self.assertStartsWith(stanza['file_id'], u'\xeed')
162
 
        self.assertStartsWith(stanza['path'], u'p\xe5th')
163
 
        if 'conflict_path' in stanza:
164
 
            self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
165
 
        if 'conflict_file_id' in stanza:
166
 
            self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
167
 
 
168
 
 
169
 
class TestConflictList(tests.TestCase):
170
 
 
171
 
    def test_stanzas_roundtrip(self):
172
 
        stanzas_iter = example_conflicts.to_stanzas()
173
 
        processed = conflicts.ConflictList.from_stanzas(stanzas_iter)
174
 
        self.assertEqual(example_conflicts, processed)
175
 
 
176
 
    def test_stringification(self):
177
 
        for text, o in zip(example_conflicts.to_strings(), example_conflicts):
178
 
            self.assertEqual(text, unicode(o))
 
146
        for stanza in example_conflicts.to_stanzas():
 
147
            if 'file_id' in stanza:
 
148
                # In Stanza form, the file_id has to be unicode.
 
149
                self.assertStartsWith(stanza['file_id'], u'\xeed')
 
150
            self.assertStartsWith(stanza['path'], u'p\xe5th')
 
151
            if 'conflict_path' in stanza:
 
152
                self.assertStartsWith(stanza['conflict_path'], u'p\xe5th')
 
153
            if 'conflict_file_id' in stanza:
 
154
                self.assertStartsWith(stanza['conflict_file_id'], u'\xeed')
179
155
 
180
156
 
181
157
# FIXME: The shell-like tests should be converted to real whitebox tests... or