bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
| 
0.8.21
by John Arbash Meinel
 Splitting up the version info code into a lazy factory style.  | 
1  | 
# Copyright (C) 2005, 2006 Canonical Ltd
 | 
2  | 
#
 | 
|
| 
0.8.1
by John Arbash Meinel
 Creating a plugin to ease generating version information from a tree.  | 
3  | 
# This program is free software; you can redistribute it and/or modify
 | 
4  | 
# it under the terms of the GNU General Public License as published by
 | 
|
5  | 
# the Free Software Foundation; either version 2 of the License, or
 | 
|
6  | 
# (at your option) any later version.
 | 
|
| 
0.8.21
by John Arbash Meinel
 Splitting up the version info code into a lazy factory style.  | 
7  | 
#
 | 
| 
0.8.1
by John Arbash Meinel
 Creating a plugin to ease generating version information from a tree.  | 
8  | 
# This program is distributed in the hope that it will be useful,
 | 
9  | 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|
10  | 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|
11  | 
# GNU General Public License for more details.
 | 
|
| 
0.8.21
by John Arbash Meinel
 Splitting up the version info code into a lazy factory style.  | 
12  | 
#
 | 
| 
0.8.1
by John Arbash Meinel
 Creating a plugin to ease generating version information from a tree.  | 
13  | 
# You should have received a copy of the GNU General Public License
 | 
14  | 
# along with this program; if not, write to the Free Software
 | 
|
15  | 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 | 
|
16  | 
||
| 
0.8.21
by John Arbash Meinel
 Splitting up the version info code into a lazy factory style.  | 
17  | 
"""Tests for version_info"""
 | 
| 
0.8.1
by John Arbash Meinel
 Creating a plugin to ease generating version information from a tree.  | 
18  | 
|
| 
2022.1.1
by John Arbash Meinel
 [merge] version-info plugin, and cleanup for layout in bzr  | 
19  | 
from cStringIO import StringIO  | 
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
20  | 
import imp  | 
| 
0.8.1
by John Arbash Meinel
 Creating a plugin to ease generating version information from a tree.  | 
21  | 
import os  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
22  | 
import sys  | 
| 
0.8.1
by John Arbash Meinel
 Creating a plugin to ease generating version information from a tree.  | 
23  | 
|
| 
3138.1.1
by John Arbash Meinel
 Fix bug #175886: version_info deprecated functions should be tested to still work.  | 
24  | 
from bzrlib import (  | 
| 
3207.1.1
by Lukáš Lalinský
 Raise a proper error when 'version-info --custom' is used without a template  | 
25  | 
errors,  | 
| 
3138.1.1
by John Arbash Meinel
 Fix bug #175886: version_info deprecated functions should be tested to still work.  | 
26  | 
symbol_versioning,  | 
27  | 
tests,  | 
|
28  | 
version_info_formats,  | 
|
29  | 
    )
 | 
|
| 
2022.1.3
by John Arbash Meinel
 Remove unused imports  | 
30  | 
from bzrlib.tests import TestCaseWithTransport  | 
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
31  | 
from bzrlib.rio import read_stanzas  | 
| 
0.8.1
by John Arbash Meinel
 Creating a plugin to ease generating version information from a tree.  | 
32  | 
|
| 
2948.4.1
by Lukáš Lalinský
 Custom template-based version info formatter.  | 
33  | 
from bzrlib.version_info_formats.format_custom import CustomVersionInfoBuilder  | 
| 
2022.1.1
by John Arbash Meinel
 [merge] version-info plugin, and cleanup for layout in bzr  | 
34  | 
from bzrlib.version_info_formats.format_rio import RioVersionInfoBuilder  | 
35  | 
from bzrlib.version_info_formats.format_python import PythonVersionInfoBuilder  | 
|
| 
0.8.1
by John Arbash Meinel
 Creating a plugin to ease generating version information from a tree.  | 
36  | 
|
37  | 
||
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
38  | 
class TestVersionInfo(TestCaseWithTransport):  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
39  | 
|
40  | 
def create_branch(self):  | 
|
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
41  | 
wt = self.make_branch_and_tree('branch')  | 
| 
0.8.23
by John Arbash Meinel
 whitespace and formatting cleanups.  | 
42  | 
|
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
43  | 
self.build_tree(['branch/a'])  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
44  | 
wt.add('a')  | 
45  | 
wt.commit('a', rev_id='r1')  | 
|
46  | 
||
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
47  | 
self.build_tree(['branch/b'])  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
48  | 
wt.add('b')  | 
49  | 
wt.commit('b', rev_id='r2')  | 
|
50  | 
||
| 
2022.1.4
by John Arbash Meinel
 test feedback from Robert.  | 
51  | 
self.build_tree_contents([('branch/a', 'new contents\n')])  | 
| 
2030.1.2
by John Arbash Meinel
 Change the version-info --format=rio to support unicode messages  | 
52  | 
wt.commit(u'\xe52', rev_id='r3')  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
53  | 
|
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
54  | 
return wt  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
55  | 
|
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
56  | 
def test_rio_version_text(self):  | 
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
57  | 
wt = self.create_branch()  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
58  | 
|
59  | 
def regen(**kwargs):  | 
|
60  | 
sio = StringIO()  | 
|
| 
0.8.23
by John Arbash Meinel
 whitespace and formatting cleanups.  | 
61  | 
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt,  | 
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
62  | 
**kwargs)  | 
63  | 
builder.generate(sio)  | 
|
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
64  | 
val = sio.getvalue()  | 
65  | 
return val  | 
|
66  | 
||
67  | 
val = regen()  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
68  | 
self.assertContainsRe(val, 'build-date:')  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
69  | 
self.assertContainsRe(val, 'date:')  | 
70  | 
self.assertContainsRe(val, 'revno: 3')  | 
|
| 
0.8.16
by John Arbash Meinel
 Using revision-id for rio, and revision_id for python  | 
71  | 
self.assertContainsRe(val, 'revision-id: r3')  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
72  | 
|
73  | 
val = regen(check_for_clean=True)  | 
|
74  | 
self.assertContainsRe(val, 'clean: True')  | 
|
75  | 
||
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
76  | 
self.build_tree(['branch/c'])  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
77  | 
val = regen(check_for_clean=True)  | 
78  | 
self.assertContainsRe(val, 'clean: False')  | 
|
79  | 
os.remove('branch/c')  | 
|
80  | 
||
81  | 
val = regen(include_revision_history=True)  | 
|
| 
0.8.6
by John Arbash Meinel
 Updated the blackbox tests.  | 
82  | 
self.assertContainsRe(val, 'id: r1')  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
83  | 
self.assertContainsRe(val, 'message: a')  | 
| 
0.8.6
by John Arbash Meinel
 Updated the blackbox tests.  | 
84  | 
self.assertContainsRe(val, 'id: r2')  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
85  | 
self.assertContainsRe(val, 'message: b')  | 
| 
0.8.6
by John Arbash Meinel
 Updated the blackbox tests.  | 
86  | 
self.assertContainsRe(val, 'id: r3')  | 
| 
2030.1.2
by John Arbash Meinel
 Change the version-info --format=rio to support unicode messages  | 
87  | 
self.assertContainsRe(val, 'message: \xc3\xa52') # utf8 encoding '\xe5'  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
88  | 
|
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
89  | 
def test_rio_version(self):  | 
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
90  | 
wt = self.create_branch()  | 
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
91  | 
|
92  | 
def regen(**kwargs):  | 
|
93  | 
sio = StringIO()  | 
|
| 
0.8.23
by John Arbash Meinel
 whitespace and formatting cleanups.  | 
94  | 
builder = RioVersionInfoBuilder(wt.branch, working_tree=wt,  | 
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
95  | 
**kwargs)  | 
96  | 
builder.generate(sio)  | 
|
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
97  | 
sio.seek(0)  | 
98  | 
stanzas = list(read_stanzas(sio))  | 
|
99  | 
self.assertEqual(1, len(stanzas))  | 
|
100  | 
return stanzas[0]  | 
|
101  | 
||
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
102  | 
def get_one_stanza(stanza, key):  | 
| 
2022.1.1
by John Arbash Meinel
 [merge] version-info plugin, and cleanup for layout in bzr  | 
103  | 
new_stanzas = list(read_stanzas(  | 
104  | 
StringIO(stanza[key].encode('utf8'))))  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
105  | 
self.assertEqual(1, len(new_stanzas))  | 
106  | 
return new_stanzas[0]  | 
|
107  | 
||
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
108  | 
stanza = regen()  | 
109  | 
self.failUnless('date' in stanza)  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
110  | 
self.failUnless('build-date' in stanza)  | 
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
111  | 
self.assertEqual(['3'], stanza.get_all('revno'))  | 
| 
0.8.16
by John Arbash Meinel
 Using revision-id for rio, and revision_id for python  | 
112  | 
self.assertEqual(['r3'], stanza.get_all('revision-id'))  | 
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
113  | 
|
114  | 
stanza = regen(check_for_clean=True)  | 
|
115  | 
self.assertEqual(['True'], stanza.get_all('clean'))  | 
|
116  | 
||
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
117  | 
self.build_tree(['branch/c'])  | 
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
118  | 
stanza = regen(check_for_clean=True, include_file_revisions=True)  | 
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
119  | 
self.assertEqual(['False'], stanza.get_all('clean'))  | 
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
120  | 
|
| 
2903.2.9
by Martin Pool
 Review cleanups, mostly documentation  | 
121  | 
        # XXX: This assumes it's being run against a repository that updates
 | 
122  | 
        # the root revision on every commit.  Newer ones that use
 | 
|
| 
2903.2.2
by Martin Pool
 doc  | 
123  | 
        # RootCommitBuilder won't update it on each commit.
 | 
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
124  | 
file_rev_stanza = get_one_stanza(stanza, 'file-revisions')  | 
| 
1731.1.50
by Aaron Bentley
 Merge bzr.dev  | 
125  | 
self.assertEqual(['', 'a', 'b', 'c'], file_rev_stanza.get_all('path'))  | 
126  | 
self.assertEqual(['r3', 'r3', 'r2', 'unversioned'],  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
127  | 
file_rev_stanza.get_all('revision'))  | 
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
128  | 
os.remove('branch/c')  | 
129  | 
||
130  | 
stanza = regen(include_revision_history=True)  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
131  | 
revision_stanza = get_one_stanza(stanza, 'revisions')  | 
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
132  | 
self.assertEqual(['r1', 'r2', 'r3'], revision_stanza.get_all('id'))  | 
| 
2030.1.2
by John Arbash Meinel
 Change the version-info --format=rio to support unicode messages  | 
133  | 
self.assertEqual(['a', 'b', u'\xe52'], revision_stanza.get_all('message'))  | 
| 
0.8.15
by John Arbash Meinel
 Including the date stamp for all revisions.  | 
134  | 
self.assertEqual(3, len(revision_stanza.get_all('date')))  | 
| 
0.8.7
by John Arbash Meinel
 Adding tests for parsing the rio text back into rio.  | 
135  | 
|
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
136  | 
        # a was modified, so it should show up modified again
 | 
137  | 
self.build_tree(['branch/a', 'branch/c'])  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
138  | 
wt.add('c')  | 
139  | 
wt.rename_one('b', 'd')  | 
|
140  | 
stanza = regen(check_for_clean=True, include_file_revisions=True)  | 
|
141  | 
file_rev_stanza = get_one_stanza(stanza, 'file-revisions')  | 
|
| 
1731.1.50
by Aaron Bentley
 Merge bzr.dev  | 
142  | 
self.assertEqual(['', 'a', 'b', 'c', 'd'],  | 
143  | 
file_rev_stanza.get_all('path'))  | 
|
144  | 
self.assertEqual(['r3', 'modified', 'renamed to d', 'new',  | 
|
145  | 
'renamed from b'],  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
146  | 
file_rev_stanza.get_all('revision'))  | 
147  | 
||
148  | 
wt.commit('modified', rev_id='r4')  | 
|
149  | 
wt.remove(['c', 'd'])  | 
|
150  | 
os.remove('branch/d')  | 
|
151  | 
stanza = regen(check_for_clean=True, include_file_revisions=True)  | 
|
152  | 
file_rev_stanza = get_one_stanza(stanza, 'file-revisions')  | 
|
| 
1731.1.50
by Aaron Bentley
 Merge bzr.dev  | 
153  | 
self.assertEqual(['', 'a', 'c', 'd'], file_rev_stanza.get_all('path'))  | 
154  | 
self.assertEqual(['r4', 'r4', 'unversioned', 'removed'],  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
155  | 
file_rev_stanza.get_all('revision'))  | 
156  | 
||
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
157  | 
def test_python_version(self):  | 
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
158  | 
wt = self.create_branch()  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
159  | 
|
160  | 
def regen(**kwargs):  | 
|
| 
2022.1.4
by John Arbash Meinel
 test feedback from Robert.  | 
161  | 
"""Create a test module, import and return it"""  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
162  | 
outf = open('test_version_information.py', 'wb')  | 
| 
2022.1.4
by John Arbash Meinel
 test feedback from Robert.  | 
163  | 
try:  | 
164  | 
builder = PythonVersionInfoBuilder(wt.branch, working_tree=wt,  | 
|
165  | 
**kwargs)  | 
|
166  | 
builder.generate(outf)  | 
|
167  | 
finally:  | 
|
168  | 
outf.close()  | 
|
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
169  | 
module_info = imp.find_module('test_version_information',  | 
170  | 
[os.getcwdu()])  | 
|
171  | 
tvi = imp.load_module('tvi', *module_info)  | 
|
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
172  | 
            # Make sure the module isn't cached
 | 
173  | 
sys.modules.pop('tvi', None)  | 
|
174  | 
sys.modules.pop('test_version_information', None)  | 
|
175  | 
            # Delete the compiled versions, because we are generating
 | 
|
176  | 
            # a new file fast enough that python doesn't detect it
 | 
|
177  | 
            # needs to recompile, and using sleep() just makes the
 | 
|
178  | 
            # test slow
 | 
|
179  | 
if os.path.exists('test_version_information.pyc'):  | 
|
180  | 
os.remove('test_version_information.pyc')  | 
|
181  | 
if os.path.exists('test_version_information.pyo'):  | 
|
182  | 
os.remove('test_version_information.pyo')  | 
|
183  | 
return tvi  | 
|
184  | 
||
185  | 
tvi = regen()  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
186  | 
self.assertEqual(3, tvi.version_info['revno'])  | 
187  | 
self.assertEqual('r3', tvi.version_info['revision_id'])  | 
|
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
188  | 
self.failUnless(tvi.version_info.has_key('date'))  | 
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
189  | 
self.assertEqual(None, tvi.version_info['clean'])  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
190  | 
|
191  | 
tvi = regen(check_for_clean=True)  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
192  | 
self.assertEqual(True, tvi.version_info['clean'])  | 
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
193  | 
|
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
194  | 
self.build_tree(['branch/c'])  | 
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
195  | 
tvi = regen(check_for_clean=True, include_file_revisions=True)  | 
196  | 
self.assertEqual(False, tvi.version_info['clean'])  | 
|
| 
1731.1.50
by Aaron Bentley
 Merge bzr.dev  | 
197  | 
self.assertEqual(['', 'a', 'b', 'c'],  | 
198  | 
sorted(tvi.file_revisions.keys()))  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
199  | 
self.assertEqual('r3', tvi.file_revisions['a'])  | 
200  | 
self.assertEqual('r2', tvi.file_revisions['b'])  | 
|
201  | 
self.assertEqual('unversioned', tvi.file_revisions['c'])  | 
|
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
202  | 
os.remove('branch/c')  | 
203  | 
||
204  | 
tvi = regen(include_revision_history=True)  | 
|
| 
0.8.15
by John Arbash Meinel
 Including the date stamp for all revisions.  | 
205  | 
|
| 
0.8.23
by John Arbash Meinel
 whitespace and formatting cleanups.  | 
206  | 
rev_info = [(rev, message) for rev, message, timestamp, timezone  | 
207  | 
in tvi.revisions]  | 
|
| 
2030.1.2
by John Arbash Meinel
 Change the version-info --format=rio to support unicode messages  | 
208  | 
self.assertEqual([('r1', 'a'), ('r2', 'b'), ('r3', u'\xe52')], rev_info)  | 
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
209  | 
|
| 
0.8.20
by John Arbash Meinel
 Updated version-info to the latest bzr.dev codebase. Changed to using VersionInfoBuilder, and made tests pass.  | 
210  | 
        # a was modified, so it should show up modified again
 | 
211  | 
self.build_tree(['branch/a', 'branch/c'])  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
212  | 
wt.add('c')  | 
213  | 
wt.rename_one('b', 'd')  | 
|
214  | 
tvi = regen(check_for_clean=True, include_file_revisions=True)  | 
|
| 
1731.1.50
by Aaron Bentley
 Merge bzr.dev  | 
215  | 
self.assertEqual(['', 'a', 'b', 'c', 'd'],  | 
216  | 
sorted(tvi.file_revisions.keys()))  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
217  | 
self.assertEqual('modified', tvi.file_revisions['a'])  | 
218  | 
self.assertEqual('renamed to d', tvi.file_revisions['b'])  | 
|
219  | 
self.assertEqual('new', tvi.file_revisions['c'])  | 
|
220  | 
self.assertEqual('renamed from b', tvi.file_revisions['d'])  | 
|
221  | 
||
222  | 
wt.commit('modified', rev_id='r4')  | 
|
223  | 
wt.remove(['c', 'd'])  | 
|
224  | 
os.remove('branch/d')  | 
|
225  | 
tvi = regen(check_for_clean=True, include_file_revisions=True)  | 
|
| 
1731.1.50
by Aaron Bentley
 Merge bzr.dev  | 
226  | 
self.assertEqual(['', 'a', 'c', 'd'],  | 
227  | 
sorted(tvi.file_revisions.keys()))  | 
|
| 
0.8.13
by John Arbash Meinel
 Including file-revisions fields, updated test suite.  | 
228  | 
self.assertEqual('r4', tvi.file_revisions['a'])  | 
229  | 
self.assertEqual('unversioned', tvi.file_revisions['c'])  | 
|
230  | 
self.assertEqual('removed', tvi.file_revisions['d'])  | 
|
| 
0.8.5
by John Arbash Meinel
 Adding some whitebox tests for the output of generate_version_info  | 
231  | 
|
| 
2948.4.1
by Lukáš Lalinský
 Custom template-based version info formatter.  | 
232  | 
def test_custom_version_text(self):  | 
233  | 
wt = self.create_branch()  | 
|
234  | 
||
235  | 
def regen(tpl, **kwargs):  | 
|
236  | 
sio = StringIO()  | 
|
237  | 
builder = CustomVersionInfoBuilder(wt.branch, working_tree=wt,  | 
|
238  | 
template=tpl, **kwargs)  | 
|
239  | 
builder.generate(sio)  | 
|
240  | 
val = sio.getvalue()  | 
|
241  | 
return val  | 
|
242  | 
||
243  | 
val = regen('build-date: "{build_date}"\ndate: "{date}"')  | 
|
244  | 
self.assertContainsRe(val, 'build-date: "[0-9-+: ]+"')  | 
|
245  | 
self.assertContainsRe(val, 'date: "[0-9-+: ]+"')  | 
|
246  | 
||
247  | 
val = regen('revno: {revno}')  | 
|
248  | 
self.assertEqual(val, 'revno: 3')  | 
|
249  | 
||
250  | 
val = regen('revision-id: {revision_id}')  | 
|
251  | 
self.assertEqual(val, 'revision-id: r3')  | 
|
252  | 
||
253  | 
val = regen('clean: {clean}', check_for_clean=True)  | 
|
254  | 
self.assertEqual(val, 'clean: 1')  | 
|
255  | 
||
256  | 
self.build_tree(['branch/c'])  | 
|
257  | 
val = regen('clean: {clean}', check_for_clean=True)  | 
|
258  | 
self.assertEqual(val, 'clean: 0')  | 
|
259  | 
os.remove('branch/c')  | 
|
| 
3138.1.1
by John Arbash Meinel
 Fix bug #175886: version_info deprecated functions should be tested to still work.  | 
260  | 
|
| 
3207.1.1
by Lukáš Lalinský
 Raise a proper error when 'version-info --custom' is used without a template  | 
261  | 
def test_custom_without_template(self):  | 
262  | 
builder = CustomVersionInfoBuilder(None)  | 
|
263  | 
sio = StringIO()  | 
|
264  | 
self.assertRaises(errors.NoTemplate, builder.generate, sio)  | 
|
265  | 
||
| 
3138.1.1
by John Arbash Meinel
 Fix bug #175886: version_info deprecated functions should be tested to still work.  | 
266  | 
|
267  | 
class TestBuilder(version_info_formats.VersionInfoBuilder):  | 
|
268  | 
    pass
 | 
|
269  | 
||
270  | 
||
271  | 
class TestVersionInfoFormatRegistry(tests.TestCase):  | 
|
272  | 
||
273  | 
def setUp(self):  | 
|
274  | 
super(TestVersionInfoFormatRegistry, self).setUp()  | 
|
275  | 
registry = version_info_formats.format_registry  | 
|
276  | 
self._default_key = registry._default_key  | 
|
277  | 
self._dict = registry._dict.copy()  | 
|
278  | 
self._help_dict = registry._help_dict.copy()  | 
|
279  | 
self._info_dict = registry._info_dict.copy()  | 
|
280  | 
self.addCleanup(self._cleanup)  | 
|
281  | 
||
282  | 
def _cleanup(self):  | 
|
283  | 
        # Restore the registry to pristine state after the test runs
 | 
|
284  | 
registry = version_info_formats.format_registry  | 
|
285  | 
registry._default_key = self._default_key  | 
|
286  | 
registry._dict = self._dict  | 
|
287  | 
registry._help_dict = self._help_dict  | 
|
288  | 
registry._info_dict = self._info_dict  | 
|
289  | 
||
290  | 
def test_register_remove(self):  | 
|
291  | 
registry = version_info_formats.format_registry  | 
|
292  | 
registry.register('testbuilder',  | 
|
293  | 
TestBuilder, 'a simple test builder')  | 
|
294  | 
self.assertIs(TestBuilder, registry.get('testbuilder'))  | 
|
295  | 
self.assertEqual('a simple test builder',  | 
|
296  | 
registry.get_help('testbuilder'))  | 
|
297  | 
registry.remove('testbuilder')  | 
|
298  | 
self.assertRaises(KeyError, registry.get, 'testbuilder')  | 
|
299  | 
||
300  | 
def test_old_functions(self):  | 
|
301  | 
self.applyDeprecated(symbol_versioning.one_zero,  | 
|
302  | 
version_info_formats.register_builder,  | 
|
303  | 
'test-builder', __name__, 'TestBuilder')  | 
|
304  | 
formats = self.applyDeprecated(symbol_versioning.one_zero,  | 
|
305  | 
version_info_formats.get_builder_formats)  | 
|
306  | 
self.failUnless('test-builder' in formats)  | 
|
307  | 
self.assertIs(TestBuilder,  | 
|
308  | 
self.applyDeprecated(symbol_versioning.one_zero,  | 
|
309  | 
version_info_formats.get_builder, 'test-builder'))  | 
|
310  | 
version_info_formats.format_registry.remove('test-builder')  |