~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_version_info.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-12-17 23:47:54 UTC
  • mfrom: (2948.4.7 version-info)
  • Revision ID: pqm@pqm.ubuntu.com-20071217234754-hzi1en08nilnvh6s
(luks) Custom template based version-info formatter

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.tests import TestCaseWithTransport
25
25
from bzrlib.rio import read_stanzas
26
26
 
 
27
from bzrlib.version_info_formats.format_custom import CustomVersionInfoBuilder
27
28
from bzrlib.version_info_formats.format_rio import RioVersionInfoBuilder
28
29
from bzrlib.version_info_formats.format_python import PythonVersionInfoBuilder
29
30
 
222
223
        self.assertEqual('unversioned', tvi.file_revisions['c'])
223
224
        self.assertEqual('removed', tvi.file_revisions['d'])
224
225
 
225
 
 
 
226
    def test_custom_version_text(self):
 
227
        wt = self.create_branch()
 
228
 
 
229
        def regen(tpl, **kwargs):
 
230
            sio = StringIO()
 
231
            builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt,
 
232
                                               template=tpl, **kwargs)
 
233
            builder.generate(sio)
 
234
            val = sio.getvalue()
 
235
            return val
 
236
 
 
237
        val = regen('build-date: "{build_date}"\ndate: "{date}"')
 
238
        self.assertContainsRe(val, 'build-date: "[0-9-+: ]+"')
 
239
        self.assertContainsRe(val, 'date: "[0-9-+: ]+"')
 
240
 
 
241
        val = regen('revno: {revno}')
 
242
        self.assertEqual(val, 'revno: 3')
 
243
 
 
244
        val = regen('revision-id: {revision_id}')
 
245
        self.assertEqual(val, 'revision-id: r3')
 
246
 
 
247
        val = regen('clean: {clean}', check_for_clean=True)
 
248
        self.assertEqual(val, 'clean: 1')
 
249
 
 
250
        self.build_tree(['branch/c'])
 
251
        val = regen('clean: {clean}', check_for_clean=True)
 
252
        self.assertEqual(val, 'clean: 0')
 
253
        os.remove('branch/c')