~jameinel/bzr-builddeb/changelog-parser

« back to all changes in this revision

Viewing changes to tests/test_merge_changelog.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-04 16:31:42 UTC
  • Revision ID: john@arbash-meinel.com-20100204163142-85hlqmp5igoabg6g
Sort out some more details for the 3-way merge code.
The main problem I was running into was that the constructor always suppressed parse failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
"""Tests for the merge_changelog code."""
21
21
 
 
22
import warnings
 
23
 
22
24
from debian_bundle import changelog
23
25
 
24
26
from bzrlib import (
177
179
  * New upstream release.
178
180
  * Awesome bug fixes.
179
181
 
180
 
 -- Joe Foo <joe@example.com> Thu, 28 Jan 2010 10:45:44 +0000
 
182
 -- Thu, 28 Jan 2010 10:45:44 +0000
181
183
 
182
 
"""
183
 
        # There are supposed to be 2 spaces after the email, yeah strict is
184
 
        # *strict*
 
184
""".splitlines(True)
 
185
        # Missing the author and we don't have allow_missing_author set
 
186
        cl = changelog.Changelog()
185
187
        self.assertRaises(changelog.ChangelogParseError,
186
 
                          changelog.Changelog, invalid_changelog, strict=True)
 
188
                          cl.parse_changelog, ''.join(invalid_changelog), strict=True)
187
189
        # If strict parsing fails, don't try to do special merging
188
190
        self.assertEqual(('not_applicable', None),
189
191
            merge_changelog.merge_changelog(invalid_changelog, v_111_2,
191
193
        self.assertEqual(('not_applicable', None),
192
194
            merge_changelog.merge_changelog(v_111_2, invalid_changelog,
193
195
                                            v_111_2))
194
 
        # Sort of a shame to fail to parse if only BASE is invalid, but we'll
195
 
        # stick with always-strict for now
196
 
        self.assertEqual(('not_applicable', None),
197
 
            merge_changelog.merge_changelog(v_111_2, v_111_2, invalid_changelog))
198
 
 
 
196
        # We are non-strict about parsing BASE, because its contents are not
 
197
        # included in the output.
 
198
        # This triggers a warning, but we don't want to clutter the test run
 
199
        cur_filters = warnings.filters[:]
 
200
        warnings.simplefilter('ignore', UserWarning)
 
201
        try:
 
202
            self.assertMergeChangelog(v_112_1 + v_111_2,
 
203
                                      this_lines=v_111_2,
 
204
                                      other_lines=v_112_1,
 
205
                                      base_lines=invalid_changelog,
 
206
                                      )
 
207
        finally:
 
208
            warnings.filters = cur_filters[:]
199
209
 
200
210
 
201
211
class TestChangelogHook(tests.TestCaseWithMemoryTransport):
231
241
    def test_changelog_merge_hook_successful(self):
232
242
        params, merger = self.make_params()
233
243
        params.other_lines = ['']
 
244
        params.base_lines = ['']
234
245
        file_merger = builddeb.changelog_merge_hook_factory(merger)
235
246
        result, new_content = file_merger.merge_text(params)
236
247
        self.assertEqual('success', result)