bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.1.55
by Martin Pool
doc |
1 |
#! /usr/bin/python2.4
|
2 |
||
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
3 |
# Copyright (C) 2005 by Canonical Ltd
|
4 |
||
5 |
# This program is free software; you can redistribute it and/or modify
|
|
6 |
# it under the terms of the GNU General Public License as published by
|
|
7 |
# the Free Software Foundation; either version 2 of the License, or
|
|
8 |
# (at your option) any later version.
|
|
9 |
||
10 |
# This program is distributed in the hope that it will be useful,
|
|
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
# GNU General Public License for more details.
|
|
14 |
||
15 |
# You should have received a copy of the GNU General Public License
|
|
16 |
# along with this program; if not, write to the Free Software
|
|
17 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
18 |
||
19 |
||
20 |
||
21 |
||
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
22 |
"""test suite for weave algorithm"""
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
23 |
|
24 |
||
25 |
from testsweet import TestBase |
|
|
0.1.47
by Martin Pool
New WeaveError and WeaveFormatError rather than assertions. |
26 |
from weave import Weave, VerInfo, WeaveFormatError |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
27 |
from pprint import pformat |
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
28 |
|
|
0.1.52
by Martin Pool
Update tests for new weave representation |
29 |
# XXX: If we do weaves this way, will a merge still behave the same
|
30 |
# way if it's done in a different order? That's a pretty desirable
|
|
31 |
# property.
|
|
32 |
||
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
33 |
|
34 |
# texts for use in testing
|
|
|
0.1.3
by Martin Pool
Change storage of texts for testing |
35 |
TEXT_0 = ["Hello world"] |
36 |
TEXT_1 = ["Hello world", |
|
37 |
"A second line"] |
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
38 |
|
39 |
||
40 |
class Easy(TestBase): |
|
41 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
42 |
k = Weave() |
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
43 |
|
44 |
||
45 |
class StoreText(TestBase): |
|
46 |
"""Store and retrieve a simple text.""" |
|
47 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
48 |
k = Weave() |
|
0.1.26
by Martin Pool
Refactor parameters to add command |
49 |
idx = k.add([], TEXT_0) |
|
0.1.4
by Martin Pool
Start indexing knits by both integer and version string. |
50 |
self.assertEqual(k.get(idx), TEXT_0) |
51 |
self.assertEqual(idx, 0) |
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
52 |
|
53 |
||
|
0.1.7
by Martin Pool
Add trivial annotate text |
54 |
|
55 |
class AnnotateOne(TestBase): |
|
56 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
57 |
k = Weave() |
|
0.1.26
by Martin Pool
Refactor parameters to add command |
58 |
k.add([], TEXT_0) |
|
0.1.7
by Martin Pool
Add trivial annotate text |
59 |
self.assertEqual(k.annotate(0), |
60 |
[(0, TEXT_0[0])]) |
|
61 |
||
62 |
||
|
0.1.5
by Martin Pool
Add test for storing two text versions. |
63 |
class StoreTwo(TestBase): |
64 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
65 |
k = Weave() |
|
0.1.5
by Martin Pool
Add test for storing two text versions. |
66 |
|
|
0.1.26
by Martin Pool
Refactor parameters to add command |
67 |
idx = k.add([], TEXT_0) |
|
0.1.5
by Martin Pool
Add test for storing two text versions. |
68 |
self.assertEqual(idx, 0) |
69 |
||
|
0.1.26
by Martin Pool
Refactor parameters to add command |
70 |
idx = k.add([], TEXT_1) |
|
0.1.5
by Martin Pool
Add test for storing two text versions. |
71 |
self.assertEqual(idx, 1) |
72 |
||
73 |
self.assertEqual(k.get(0), TEXT_0) |
|
74 |
self.assertEqual(k.get(1), TEXT_1) |
|
75 |
||
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
76 |
k.dump(self.TEST_LOG) |
77 |
||
78 |
||
|
0.1.21
by Martin Pool
Start computing a delta to insert a new revision |
79 |
|
|
0.1.55
by Martin Pool
doc |
80 |
class DeltaAdd(TestBase): |
|
0.1.21
by Martin Pool
Start computing a delta to insert a new revision |
81 |
"""Detection of changes prior to inserting new revision.""" |
82 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
83 |
k = Weave() |
|
0.1.26
by Martin Pool
Refactor parameters to add command |
84 |
k.add([], ['line 1']) |
|
0.1.21
by Martin Pool
Start computing a delta to insert a new revision |
85 |
|
|
0.1.52
by Martin Pool
Update tests for new weave representation |
86 |
self.assertEqual(k._l, |
87 |
[('{', 0), |
|
88 |
'line 1', |
|
89 |
('}', 0), |
|
90 |
])
|
|
91 |
||
|
0.1.22
by Martin Pool
Calculate delta for new versions relative to a set of parent versions. |
92 |
changes = list(k._delta(set([0]), |
93 |
['line 1', |
|
94 |
'new line'])) |
|
|
0.1.21
by Martin Pool
Start computing a delta to insert a new revision |
95 |
|
96 |
self.log('raw changes: ' + pformat(changes)) |
|
97 |
||
|
0.1.52
by Martin Pool
Update tests for new weave representation |
98 |
# currently there are 3 lines in the weave, and we insert after them
|
|
0.1.22
by Martin Pool
Calculate delta for new versions relative to a set of parent versions. |
99 |
self.assertEquals(changes, |
|
0.1.52
by Martin Pool
Update tests for new weave representation |
100 |
[(3, 3, ['new line'])]) |
|
0.1.22
by Martin Pool
Calculate delta for new versions relative to a set of parent versions. |
101 |
|
|
0.1.24
by Martin Pool
Add another change for delta of new version. |
102 |
changes = k._delta(set([0]), |
103 |
['top line', |
|
104 |
'line 1']) |
|
105 |
||
106 |
self.assertEquals(list(changes), |
|
|
0.1.54
by Martin Pool
Fix weave line calculation when making deltas |
107 |
[(1, 1, ['top line'])]) |
|
0.1.24
by Martin Pool
Add another change for delta of new version. |
108 |
|
109 |
||
|
0.1.21
by Martin Pool
Start computing a delta to insert a new revision |
110 |
|
|
0.1.27
by Martin Pool
Check that version numbers passed in are reasonable |
111 |
class InvalidAdd(TestBase): |
112 |
"""Try to use invalid version number during add.""" |
|
113 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
114 |
k = Weave() |
|
0.1.27
by Martin Pool
Check that version numbers passed in are reasonable |
115 |
|
116 |
self.assertRaises(IndexError, |
|
117 |
k.add, |
|
118 |
[69], |
|
119 |
['new text!']) |
|
120 |
||
121 |
||
|
0.1.26
by Martin Pool
Refactor parameters to add command |
122 |
class InsertLines(TestBase): |
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
123 |
"""Store a revision that adds one line to the original. |
124 |
||
125 |
Look at the annotations to make sure that the first line is matched
|
|
126 |
and not stored repeatedly."""
|
|
127 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
128 |
k = Weave() |
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
129 |
|
|
0.1.26
by Martin Pool
Refactor parameters to add command |
130 |
k.add([], ['line 1']) |
131 |
k.add([0], ['line 1', 'line 2']) |
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
132 |
|
133 |
self.assertEqual(k.annotate(0), |
|
134 |
[(0, 'line 1')]) |
|
135 |
||
|
0.1.25
by Martin Pool
Handle insertion of new weave layers that insert text on top of the basis |
136 |
self.assertEqual(k.get(1), |
137 |
['line 1', |
|
138 |
'line 2']) |
|
139 |
||
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
140 |
self.assertEqual(k.annotate(1), |
141 |
[(0, 'line 1'), |
|
142 |
(1, 'line 2')]) |
|
143 |
||
|
0.1.28
by Martin Pool
More tests for insertion of lines in new versions. |
144 |
k.add([0], ['line 1', 'diverged line']) |
145 |
||
146 |
self.assertEqual(k.annotate(2), |
|
147 |
[(0, 'line 1'), |
|
148 |
(2, 'diverged line')]) |
|
149 |
||
|
0.1.54
by Martin Pool
Fix weave line calculation when making deltas |
150 |
text3 = ['line 1', 'middle line', 'line 2'] |
|
0.1.28
by Martin Pool
More tests for insertion of lines in new versions. |
151 |
k.add([0, 1], |
|
0.1.54
by Martin Pool
Fix weave line calculation when making deltas |
152 |
text3) |
153 |
||
154 |
self.log("changes to text3: " + pformat(list(k._delta(set([0, 1]), text3)))) |
|
155 |
||
156 |
self.log("k._l=" + pformat(k._l)) |
|
|
0.1.28
by Martin Pool
More tests for insertion of lines in new versions. |
157 |
|
158 |
self.assertEqual(k.annotate(3), |
|
159 |
[(0, 'line 1'), |
|
160 |
(3, 'middle line'), |
|
161 |
(1, 'line 2')]) |
|
162 |
||
|
0.1.31
by Martin Pool
Fix insertion of multiple regions, calculating the right line offset as we go. |
163 |
# now multiple insertions at different places
|
164 |
k.add([0, 1, 3], |
|
165 |
['line 1', 'aaa', 'middle line', 'bbb', 'line 2', 'ccc']) |
|
166 |
||
167 |
self.assertEqual(k.annotate(4), |
|
168 |
[(0, 'line 1'), |
|
169 |
(4, 'aaa'), |
|
170 |
(3, 'middle line'), |
|
171 |
(4, 'bbb'), |
|
172 |
(1, 'line 2'), |
|
173 |
(4, 'ccc')]) |
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
174 |
|
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
175 |
|
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
176 |
|
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
177 |
class DeleteLines(TestBase): |
178 |
"""Deletion of lines from existing text. |
|
179 |
||
180 |
Try various texts all based on a common ancestor."""
|
|
181 |
def runTest(self): |
|
182 |
k = Weave() |
|
183 |
||
184 |
base_text = ['one', 'two', 'three', 'four'] |
|
185 |
||
186 |
k.add([], base_text) |
|
187 |
||
188 |
texts = [['one', 'two', 'three'], |
|
189 |
['two', 'three', 'four'], |
|
190 |
['one', 'four'], |
|
191 |
['one', 'two', 'three', 'four'], |
|
192 |
]
|
|
193 |
||
194 |
for t in texts: |
|
195 |
ver = k.add([0], t) |
|
196 |
||
197 |
self.log('final weave:') |
|
198 |
self.log('k._l=' + pformat(k._l)) |
|
199 |
||
200 |
for i in range(len(texts)): |
|
201 |
self.assertEqual(k.get(i+1), |
|
202 |
texts[i]) |
|
203 |
||
204 |
||
205 |
||
206 |
||
|
0.1.49
by Martin Pool
Add another constraint: revisions should not delete text that they |
207 |
class SuicideDelete(TestBase): |
|
0.1.55
by Martin Pool
doc |
208 |
"""Invalid weave which tries to add and delete simultaneously.""" |
|
0.1.49
by Martin Pool
Add another constraint: revisions should not delete text that they |
209 |
def runTest(self): |
210 |
k = Weave() |
|
211 |
||
212 |
k._v = [VerInfo([]), |
|
213 |
]
|
|
214 |
k._l = [('{', 0), |
|
215 |
'first line', |
|
216 |
('[', 0), |
|
217 |
'deleted in 0', |
|
218 |
(']', 0), |
|
219 |
('}', 0), |
|
220 |
]
|
|
221 |
||
222 |
self.assertRaises(WeaveFormatError, |
|
223 |
k.get, |
|
224 |
0) |
|
225 |
||
226 |
||
227 |
||
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
228 |
class CannedDelete(TestBase): |
229 |
"""Unpack canned weave with deleted lines.""" |
|
230 |
def runTest(self): |
|
231 |
k = Weave() |
|
232 |
||
233 |
k._v = [VerInfo([]), |
|
234 |
VerInfo([0]), |
|
235 |
]
|
|
236 |
k._l = [('{', 0), |
|
237 |
'first line', |
|
238 |
('[', 1), |
|
239 |
'line to be deleted', |
|
240 |
(']', 1), |
|
241 |
'last line', |
|
242 |
('}', 0), |
|
243 |
]
|
|
244 |
||
245 |
self.assertEqual(k.get(0), |
|
246 |
['first line', |
|
247 |
'line to be deleted', |
|
248 |
'last line', |
|
249 |
])
|
|
250 |
||
|
0.1.50
by Martin Pool
Basic implementation of deletion markers |
251 |
self.assertEqual(k.get(1), |
252 |
['first line', |
|
253 |
'last line', |
|
254 |
])
|
|
255 |
||
|
0.1.48
by Martin Pool
Basic parsing of delete instructions. |
256 |
|
257 |
||
|
0.1.51
by Martin Pool
Add test for replacement lines |
258 |
class CannedReplacement(TestBase): |
259 |
"""Unpack canned weave with deleted lines.""" |
|
260 |
def runTest(self): |
|
261 |
k = Weave() |
|
262 |
||
263 |
k._v = [VerInfo([]), |
|
264 |
VerInfo([0]), |
|
265 |
]
|
|
266 |
k._l = [('{', 0), |
|
267 |
'first line', |
|
268 |
('[', 1), |
|
269 |
'line to be deleted', |
|
270 |
(']', 1), |
|
271 |
('{', 1), |
|
272 |
'replacement line', |
|
273 |
('}', 1), |
|
274 |
'last line', |
|
275 |
('}', 0), |
|
276 |
]
|
|
277 |
||
278 |
self.assertEqual(k.get(0), |
|
279 |
['first line', |
|
280 |
'line to be deleted', |
|
281 |
'last line', |
|
282 |
])
|
|
283 |
||
284 |
self.assertEqual(k.get(1), |
|
285 |
['first line', |
|
286 |
'replacement line', |
|
287 |
'last line', |
|
288 |
])
|
|
289 |
||
290 |
||
291 |
||
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
292 |
class BadWeave(TestBase): |
293 |
"""Test that we trap an insert which should not occur.""" |
|
294 |
def runTest(self): |
|
295 |
k = Weave() |
|
296 |
||
297 |
k._v = [VerInfo([]), |
|
298 |
]
|
|
299 |
k._l = ['bad line', |
|
300 |
('{', 0), |
|
301 |
'foo {', |
|
302 |
('{', 1), |
|
303 |
' added in version 1', |
|
304 |
('{', 2), |
|
305 |
' added in v2', |
|
306 |
('}', 2), |
|
307 |
' also from v1', |
|
308 |
('}', 1), |
|
309 |
'}', |
|
310 |
('}', 0)] |
|
311 |
||
|
0.1.47
by Martin Pool
New WeaveError and WeaveFormatError rather than assertions. |
312 |
self.assertRaises(WeaveFormatError, |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
313 |
k.get, |
314 |
0) |
|
315 |
||
316 |
||
317 |
class BadInsert(TestBase): |
|
318 |
"""Test that we trap an insert which should not occur.""" |
|
319 |
def runTest(self): |
|
320 |
k = Weave() |
|
321 |
||
322 |
k._v = [VerInfo([]), |
|
323 |
VerInfo([0]), |
|
324 |
VerInfo([0]), |
|
325 |
VerInfo([0,1,2]), |
|
326 |
]
|
|
327 |
k._l = [('{', 0), |
|
328 |
'foo {', |
|
329 |
('{', 1), |
|
330 |
' added in version 1', |
|
331 |
('{', 1), |
|
332 |
' more in 1', |
|
333 |
('}', 1), |
|
334 |
('}', 1), |
|
335 |
('}', 0)] |
|
336 |
||
|
0.1.47
by Martin Pool
New WeaveError and WeaveFormatError rather than assertions. |
337 |
self.assertRaises(WeaveFormatError, |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
338 |
k.get, |
339 |
0) |
|
340 |
||
|
0.1.47
by Martin Pool
New WeaveError and WeaveFormatError rather than assertions. |
341 |
self.assertRaises(WeaveFormatError, |
|
0.1.46
by Martin Pool
More constraints on structure of weave, and checks that they work |
342 |
k.get, |
343 |
1) |
|
344 |
||
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
345 |
|
346 |
class InsertNested(TestBase): |
|
347 |
"""Insertion with nested instructions.""" |
|
348 |
def runTest(self): |
|
349 |
k = Weave() |
|
350 |
||
351 |
k._v = [VerInfo([]), |
|
352 |
VerInfo([0]), |
|
353 |
VerInfo([0]), |
|
|
0.1.44
by Martin Pool
More tests for nested insert instructions |
354 |
VerInfo([0,1,2]), |
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
355 |
]
|
356 |
k._l = [('{', 0), |
|
357 |
'foo {', |
|
358 |
('{', 1), |
|
359 |
' added in version 1', |
|
|
0.1.42
by Martin Pool
More tests for nested insert instructions |
360 |
('{', 2), |
361 |
' added in v2', |
|
362 |
('}', 2), |
|
363 |
' also from v1', |
|
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
364 |
('}', 1), |
365 |
'}', |
|
366 |
('}', 0)] |
|
367 |
||
368 |
self.assertEqual(k.get(0), |
|
369 |
['foo {', |
|
370 |
'}']) |
|
371 |
||
372 |
self.assertEqual(k.get(1), |
|
373 |
['foo {', |
|
374 |
' added in version 1', |
|
|
0.1.42
by Martin Pool
More tests for nested insert instructions |
375 |
' also from v1', |
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
376 |
'}']) |
377 |
||
|
0.1.44
by Martin Pool
More tests for nested insert instructions |
378 |
self.assertEqual(k.get(2), |
379 |
['foo {', |
|
380 |
' added in v2', |
|
381 |
'}']) |
|
382 |
||
383 |
self.assertEqual(k.get(3), |
|
384 |
['foo {', |
|
385 |
' added in version 1', |
|
386 |
' added in v2', |
|
387 |
' also from v1', |
|
388 |
'}']) |
|
389 |
||
|
0.1.45
by Martin Pool
doc |
390 |
|
|
0.1.40
by Martin Pool
Add test for extracting from weave with nested insertions |
391 |
|
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
392 |
class DeleteLines2(TestBase): |
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
393 |
"""Test recording revisions that delete lines. |
394 |
||
395 |
This relies on the weave having a way to represent lines knocked
|
|
396 |
out by a later revision."""
|
|
397 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
398 |
k = Weave() |
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
399 |
|
400 |
k.add([], ["line the first", |
|
401 |
"line 2", |
|
402 |
"line 3", |
|
403 |
"fine"]) |
|
404 |
||
405 |
self.assertEqual(len(k.get(0)), 4) |
|
406 |
||
407 |
k.add([0], ["line the first", |
|
408 |
"fine"]) |
|
409 |
||
410 |
self.assertEqual(k.get(1), |
|
411 |
["line the first", |
|
412 |
"fine"]) |
|
413 |
||
|
0.1.56
by Martin Pool
Handle deletion of lines by marking the region with a deletion |
414 |
self.assertEqual(k.annotate(1), |
415 |
[(0, "line the first"), |
|
416 |
(0, "fine")]) |
|
417 |
||
|
0.1.30
by Martin Pool
Start adding tests for line deletion |
418 |
|
|
0.1.26
by Martin Pool
Refactor parameters to add command |
419 |
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
420 |
class IncludeVersions(TestBase): |
421 |
"""Check texts that are stored across multiple revisions. |
|
422 |
||
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
423 |
Here we manually create a weave with particular encoding and make
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
424 |
sure it unpacks properly.
|
425 |
||
426 |
Text 0 includes nothing; text 1 includes text 0 and adds some
|
|
427 |
lines.
|
|
428 |
"""
|
|
429 |
||
430 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
431 |
k = Weave() |
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
432 |
|
|
0.1.17
by Martin Pool
Use objects rather than tuples for tracking VerInfo for |
433 |
k._v = [VerInfo(), VerInfo(included=[0])] |
|
0.1.39
by Martin Pool
Change to a more realistic weave structure which can represent insertions and |
434 |
k._l = [('{', 0), |
435 |
"first line", |
|
436 |
('}', 0), |
|
437 |
('{', 1), |
|
438 |
"second line", |
|
439 |
('}', 1)] |
|
|
0.1.13
by Martin Pool
Knit structure now allows for versions to include the lines present in other |
440 |
|
441 |
self.assertEqual(k.get(1), |
|
442 |
["first line", |
|
443 |
"second line"]) |
|
444 |
||
445 |
self.assertEqual(k.get(0), |
|
446 |
["first line"]) |
|
447 |
||
448 |
k.dump(self.TEST_LOG) |
|
449 |
||
|
0.1.5
by Martin Pool
Add test for storing two text versions. |
450 |
|
|
0.1.14
by Martin Pool
Another test for version inclusion |
451 |
class DivergedIncludes(TestBase): |
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
452 |
"""Weave with two diverged texts based on version 0. |
|
0.1.14
by Martin Pool
Another test for version inclusion |
453 |
"""
|
454 |
def runTest(self): |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
455 |
k = Weave() |
|
0.1.14
by Martin Pool
Another test for version inclusion |
456 |
|
|
0.1.17
by Martin Pool
Use objects rather than tuples for tracking VerInfo for |
457 |
k._v = [VerInfo(), |
458 |
VerInfo(included=[0]), |
|
459 |
VerInfo(included=[0]), |
|
460 |
]
|
|
|
0.1.39
by Martin Pool
Change to a more realistic weave structure which can represent insertions and |
461 |
k._l = [('{', 0), |
462 |
"first line", |
|
463 |
('}', 0), |
|
464 |
('{', 1), |
|
465 |
"second line", |
|
466 |
('}', 1), |
|
467 |
('{', 2), |
|
468 |
"alternative second line", |
|
469 |
('}', 2), |
|
470 |
]
|
|
|
0.1.14
by Martin Pool
Another test for version inclusion |
471 |
|
472 |
self.assertEqual(k.get(0), |
|
473 |
["first line"]) |
|
474 |
||
475 |
self.assertEqual(k.get(1), |
|
476 |
["first line", |
|
477 |
"second line"]) |
|
478 |
||
479 |
self.assertEqual(k.get(2), |
|
480 |
["first line", |
|
481 |
"alternative second line"]) |
|
482 |
||
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
483 |
|
484 |
||
485 |
class ReplaceLine(TestBase): |
|
486 |
def runTest(self): |
|
487 |
k = Weave() |
|
488 |
||
489 |
text0 = ['cheddar', 'stilton', 'gruyere'] |
|
490 |
text1 = ['cheddar', 'blue vein', 'neufchatel', 'chevre'] |
|
491 |
||
492 |
k.add([], text0) |
|
493 |
k.add([0], text1) |
|
494 |
||
495 |
self.log('k._l=' + pformat(k._l)) |
|
496 |
||
|
0.1.59
by Martin Pool
More modification tests |
497 |
self.assertEqual(k.get(0), text0) |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
498 |
self.assertEqual(k.get(1), text1) |
499 |
||
500 |
||
501 |
||
502 |
||
503 |
class Khayyam(TestBase): |
|
504 |
def runTest(self): |
|
505 |
rawtexts = [ |
|
506 |
"""A Book of Verses underneath the Bough, |
|
507 |
A Jug of Wine, a Loaf of Bread, -- and Thou
|
|
508 |
Beside me singing in the Wilderness --
|
|
509 |
Oh, Wilderness were Paradise enow!""", |
|
510 |
|
|
511 |
"""A Book of Verses underneath the Bough, |
|
512 |
A Jug of Wine, a Loaf of Bread, -- and Thou
|
|
513 |
Beside me singing in the Wilderness --
|
|
514 |
Oh, Wilderness were Paradise now!""", |
|
|
0.1.59
by Martin Pool
More modification tests |
515 |
|
516 |
"""A Book of poems underneath the tree, |
|
517 |
A Jug of Wine, a Loaf of Bread,
|
|
518 |
and Thou
|
|
519 |
Beside me singing in the Wilderness --
|
|
520 |
Oh, Wilderness were Paradise now!
|
|
521 |
||
522 |
-- O. Khayyam""", |
|
523 |
||
524 |
"""A Book of Verses underneath the Bough, |
|
525 |
A Jug of Wine, a Loaf of Bread,
|
|
526 |
and Thou
|
|
527 |
Beside me singing in the Wilderness --
|
|
528 |
Oh, Wilderness were Paradise now!
|
|
529 |
""", |
|
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
530 |
]
|
531 |
texts = [[l.strip() for l in t.split('\n')] for t in rawtexts] |
|
532 |
||
533 |
k = Weave() |
|
534 |
parents = set() |
|
535 |
for t in texts: |
|
536 |
ver = k.add(parents, t) |
|
537 |
parents.add(ver) |
|
538 |
||
|
0.1.59
by Martin Pool
More modification tests |
539 |
self.log("k._l=" + pformat(k._l)) |
540 |
||
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
541 |
for i, t in enumerate(texts): |
542 |
self.assertEqual(k.get(i), |
|
543 |
t) |
|
544 |
||
545 |
||
546 |
||
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
547 |
def testweave(): |
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
548 |
import testsweet |
549 |
from unittest import TestSuite, TestLoader |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
550 |
import testweave |
|
0.1.57
by Martin Pool
Fix bug in an update edit that both deletes and inserts -- previously |
551 |
|
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
552 |
tl = TestLoader() |
553 |
suite = TestSuite() |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
554 |
suite.addTest(tl.loadTestsFromModule(testweave)) |
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
555 |
|
|
0.1.15
by Martin Pool
Fix inverted shell return code for testknit |
556 |
return int(not testsweet.run_suite(suite)) # for shell 0=true |
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
557 |
|
558 |
||
559 |
if __name__ == '__main__': |
|
560 |
import sys |
|
|
0.1.38
by Martin Pool
Rename knit to weave. (I don't think there's an existing module called weave.) |
561 |
sys.exit(testweave()) |
|
0.1.2
by Martin Pool
Import testsweet module adapted from bzr. |
562 |