bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.54.76
by Vincent Ladeuil
Fix the broken test. |
1 |
# Copyright (C) 2007-2010 Canonical Ltd
|
|
0.54.61
by Jeff Licquia
Assign copyright to Canonical. |
2 |
#
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
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
|
|
|
0.54.61
by Jeff Licquia
Assign copyright to Canonical. |
6 |
# (at your option) any later version.
|
|
0.54.57
by Jeff Licquia
Check and fix more PEP 8 failures. |
7 |
#
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
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.54.57
by Jeff Licquia
Check and fix more PEP 8 failures. |
12 |
#
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
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
|
|
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
16 |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
17 |
"Test suite for the bzr bisect plugin."
|
18 |
||
|
6625.4.4
by Jelmer Vernooij
Drop meta file. |
19 |
from __future__ import absolute_import |
20 |
||
|
0.54.78
by Jelmer Vernooij
Merge several improvements from Gustaf: |
21 |
from cStringIO import StringIO |
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
22 |
import os |
|
0.54.41
by Jeff Licquia
Add a merged subtree to the repo the tests create. |
23 |
import shutil |
|
0.54.78
by Jelmer Vernooij
Merge several improvements from Gustaf: |
24 |
|
|
6656.2.5
by Jelmer Vernooij
Fix import. |
25 |
from ..controldir import ControlDir |
|
6625.4.1
by Jelmer Vernooij
Merge bisect. |
26 |
from .. import bisect |
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
27 |
from . import ( |
|
0.62.1
by Jelmer Vernooij
Lazy load plugin. |
28 |
TestCaseWithTransport, |
|
0.54.78
by Jelmer Vernooij
Merge several improvements from Gustaf: |
29 |
TestSkipped, |
30 |
)
|
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
31 |
|
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
32 |
|
|
0.62.1
by Jelmer Vernooij
Lazy load plugin. |
33 |
class BisectTestCase(TestCaseWithTransport): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
34 |
"""Test harness specific to the bisect plugin.""" |
|
0.54.57
by Jeff Licquia
Check and fix more PEP 8 failures. |
35 |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
36 |
def assertRevno(self, rev): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
37 |
"""Make sure we're at the right revision.""" |
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
38 |
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
39 |
rev_contents = {1: "one", 1.1: "one dot one", 1.2: "one dot two", |
40 |
1.3: "one dot three", 2: "two", 3: "three", |
|
41 |
4: "four", 5: "five"} |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
42 |
|
|
6656.1.1
by Martin
Apply 2to3 dict fixer and clean up resulting mess using view helpers |
43 |
with open("test_file") as f: |
44 |
content = f.read().strip() |
|
|
0.54.50
by Jeff Licquia
Better diagnostics when an assertRevno() call fails. |
45 |
if content != rev_contents[rev]: |
|
6656.1.3
by Martin
Now this really is the biggest of the big |
46 |
rev_ids = dict((rev_contents[k], k) for k in rev_contents) |
|
0.54.50
by Jeff Licquia
Better diagnostics when an assertRevno() call fails. |
47 |
found_rev = rev_ids[content] |
48 |
raise AssertionError("expected rev %0.1f, found rev %0.1f" |
|
49 |
% (rev, found_rev)) |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
50 |
|
51 |
def setUp(self): |
|
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
52 |
"""Set up tests.""" |
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
53 |
|
|
0.54.41
by Jeff Licquia
Add a merged subtree to the repo the tests create. |
54 |
# These tests assume a branch with five revisions, and
|
55 |
# a branch from version 1 containing three revisions
|
|
56 |
# merged at version 2.
|
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
57 |
|
|
0.62.1
by Jelmer Vernooij
Lazy load plugin. |
58 |
TestCaseWithTransport.setUp(self) |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
59 |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
60 |
self.tree = self.make_branch_and_tree(".") |
61 |
||
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
62 |
test_file = open("test_file", "w") |
63 |
test_file.write("one") |
|
64 |
test_file.close() |
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
65 |
self.tree.add(self.tree.relpath(os.path.join(os.getcwd(), |
66 |
'test_file'))) |
|
|
0.60.1
by Gustaf Thorslund
Added test cases for running a test script: |
67 |
test_file_append = open("test_file_append", "a") |
68 |
test_file_append.write("one\n") |
|
69 |
test_file_append.close() |
|
70 |
self.tree.add(self.tree.relpath(os.path.join(os.getcwd(), |
|
71 |
'test_file_append'))) |
|
72 |
self.tree.commit(message = "add test files") |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
73 |
|
|
6667.2.1
by Jelmer Vernooij
Some cleanup; s/BzrDir/ControlDir/, remove some unused imports. |
74 |
ControlDir.open(".").sprout("../temp-clone") |
75 |
clone_bzrdir = ControlDir.open("../temp-clone") |
|
|
0.54.41
by Jeff Licquia
Add a merged subtree to the repo the tests create. |
76 |
clone_tree = clone_bzrdir.open_workingtree() |
77 |
for content in ["one dot one", "one dot two", "one dot three"]: |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
78 |
test_file = open("../temp-clone/test_file", "w") |
79 |
test_file.write(content) |
|
80 |
test_file.close() |
|
|
0.60.1
by Gustaf Thorslund
Added test cases for running a test script: |
81 |
test_file_append = open("../temp-clone/test_file_append", "a") |
82 |
test_file_append.write(content + "\n") |
|
83 |
test_file_append.close() |
|
|
0.54.41
by Jeff Licquia
Add a merged subtree to the repo the tests create. |
84 |
clone_tree.commit(message = "make branch test change") |
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
85 |
saved_subtree_revid = clone_tree.branch.last_revision() |
|
0.54.41
by Jeff Licquia
Add a merged subtree to the repo the tests create. |
86 |
|
87 |
self.tree.merge_from_branch(clone_tree.branch) |
|
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
88 |
test_file = open("test_file", "w") |
89 |
test_file.write("two") |
|
90 |
test_file.close() |
|
|
0.60.1
by Gustaf Thorslund
Added test cases for running a test script: |
91 |
test_file_append = open("test_file_append", "a") |
92 |
test_file_append.write("two\n") |
|
93 |
test_file_append.close() |
|
|
0.54.41
by Jeff Licquia
Add a merged subtree to the repo the tests create. |
94 |
self.tree.commit(message = "merge external branch") |
95 |
shutil.rmtree("../temp-clone") |
|
96 |
||
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
97 |
self.subtree_rev = saved_subtree_revid |
98 |
||
|
0.54.41
by Jeff Licquia
Add a merged subtree to the repo the tests create. |
99 |
file_contents = ["three", "four", "five"] |
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
100 |
for content in file_contents: |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
101 |
test_file = open("test_file", "w") |
102 |
test_file.write(content) |
|
103 |
test_file.close() |
|
|
0.60.1
by Gustaf Thorslund
Added test cases for running a test script: |
104 |
test_file_append = open("test_file_append", "a") |
105 |
test_file_append.write(content + "\n") |
|
106 |
test_file_append.close() |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
107 |
self.tree.commit(message = "make test change") |
108 |
||
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
109 |
|
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
110 |
class BisectHarnessTests(BisectTestCase): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
111 |
"""Tests for the harness itself.""" |
|
0.54.57
by Jeff Licquia
Check and fix more PEP 8 failures. |
112 |
|
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
113 |
def testLastRev(self): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
114 |
"""Test that the last revision is correct.""" |
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
115 |
repo = self.tree.branch.repository |
116 |
top_revtree = repo.revision_tree(self.tree.last_revision()) |
|
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
117 |
top_revtree.lock_read() |
118 |
top_file = top_revtree.get_file(top_revtree.path2id("test_file")) |
|
119 |
test_content = top_file.read().strip() |
|
120 |
top_file.close() |
|
121 |
top_revtree.unlock() |
|
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
122 |
self.assertEqual(test_content, "five") |
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
123 |
|
124 |
def testSubtreeRev(self): |
|
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
125 |
"""Test that the last revision in a subtree is correct.""" |
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
126 |
repo = self.tree.branch.repository |
127 |
sub_revtree = repo.revision_tree(self.subtree_rev) |
|
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
128 |
sub_revtree.lock_read() |
129 |
sub_file = sub_revtree.get_file(sub_revtree.path2id("test_file")) |
|
130 |
test_content = sub_file.read().strip() |
|
131 |
sub_file.close() |
|
132 |
sub_revtree.unlock() |
|
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
133 |
self.assertEqual(test_content, "one dot three") |
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
134 |
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
135 |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
136 |
class BisectCurrentUnitTests(BisectTestCase): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
137 |
"""Test the BisectCurrent class.""" |
|
0.54.57
by Jeff Licquia
Check and fix more PEP 8 failures. |
138 |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
139 |
def testShowLog(self): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
140 |
"""Test that the log can be shown.""" |
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
141 |
# Not a very good test; just makes sure the code doesn't fail,
|
142 |
# not that the output makes any sense.
|
|
|
0.54.72
by James Westby
Start to remove the use of sys.stdout. |
143 |
sio = StringIO() |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
144 |
bisect.BisectCurrent(self.tree.controldir).show_rev_log(out=sio) |
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
145 |
|
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
146 |
def testShowLogSubtree(self): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
147 |
"""Test that a subtree's log can be shown.""" |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
148 |
current = bisect.BisectCurrent(self.tree.controldir) |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
149 |
current.switch(self.subtree_rev) |
|
0.54.72
by James Westby
Start to remove the use of sys.stdout. |
150 |
sio = StringIO() |
151 |
current.show_rev_log(out=sio) |
|
|
0.54.49
by Jeff Licquia
Add subtree and harness tests. |
152 |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
153 |
def testSwitchVersions(self): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
154 |
"""Test switching versions.""" |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
155 |
current = bisect.BisectCurrent(self.tree.controldir) |
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
156 |
self.assertRevno(5) |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
157 |
current.switch(4) |
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
158 |
self.assertRevno(4) |
159 |
||
160 |
def testReset(self): |
|
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
161 |
"""Test resetting the working tree to a non-bisected state.""" |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
162 |
current = bisect.BisectCurrent(self.tree.controldir) |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
163 |
current.switch(4) |
164 |
current.reset() |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
165 |
self.assertRevno(5) |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
166 |
self.assertFalse(os.path.exists( |
167 |
os.path.join('.bzr', bisect.BISECT_REV_PATH))) |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
168 |
|
|
0.54.43
by Jeff Licquia
Add non-functioning is_merge_point() method to BisectCurrent. |
169 |
def testIsMergePoint(self): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
170 |
"""Test merge point detection.""" |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
171 |
current = bisect.BisectCurrent(self.tree.controldir) |
|
0.54.43
by Jeff Licquia
Add non-functioning is_merge_point() method to BisectCurrent. |
172 |
self.assertRevno(5) |
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
173 |
self.assertFalse(current.is_merge_point()) |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
174 |
current.switch(2) |
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
175 |
self.assertTrue(current.is_merge_point()) |
|
0.54.43
by Jeff Licquia
Add non-functioning is_merge_point() method to BisectCurrent. |
176 |
|
|
0.54.52
by Jeff Licquia
PEP 8 fixes. |
177 |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
178 |
class BisectLogUnitTests(BisectTestCase): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
179 |
"""Test the BisectLog class.""" |
|
0.54.57
by Jeff Licquia
Check and fix more PEP 8 failures. |
180 |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
181 |
def testCreateBlank(self): |
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
182 |
"""Test creation of new log.""" |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
183 |
bisect_log = bisect.BisectLog(self.tree.controldir) |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
184 |
bisect_log.save() |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
185 |
self.assertTrue( |
186 |
os.path.exists(os.path.join('.bzr', bisect.BISECT_INFO_PATH))) |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
187 |
|
188 |
def testLoad(self): |
|
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
189 |
"""Test loading a log.""" |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
190 |
preloaded_log = open(os.path.join('.bzr', bisect.BISECT_INFO_PATH), "w") |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
191 |
preloaded_log.write("rev1 yes\nrev2 no\nrev3 yes\n") |
192 |
preloaded_log.close() |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
193 |
|
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
194 |
bisect_log = bisect.BisectLog(self.tree.controldir) |
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
195 |
self.assertEqual(len(bisect_log._items), 3) |
196 |
self.assertEqual(bisect_log._items[0], ("rev1", "yes")) |
|
197 |
self.assertEqual(bisect_log._items[1], ("rev2", "no")) |
|
198 |
self.assertEqual(bisect_log._items[2], ("rev3", "yes")) |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
199 |
|
200 |
def testSave(self): |
|
|
0.60.4
by Gustaf Thorslund
Fixed " -> """ for docstrings. Added some docstrings. Also converted some #-comment into a docstring. |
201 |
"""Test saving the log.""" |
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
202 |
bisect_log = bisect.BisectLog(self.tree.controldir) |
|
0.54.56
by Jeff Licquia
Fix some pylint complaints. |
203 |
bisect_log._items = [("rev1", "yes"), ("rev2", "no"), ("rev3", "yes")] |
204 |
bisect_log.save() |
|
|
0.54.40
by Jeff Licquia
Move the tests to their own module. |
205 |
|
|
6681.2.2
by Jelmer Vernooij
Use controldir API in bisect. |
206 |
with open(os.path.join('.bzr', bisect.BISECT_INFO_PATH)) as logfile: |
|
6656.2.1
by Jelmer Vernooij
Integrate bisect command into core. |
207 |
self.assertEqual(logfile.read(), "rev1 yes\nrev2 no\nrev3 yes\n") |