~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/testweave.py

  • Committer: Martin Pool
  • Date: 2005-09-05 04:08:03 UTC
  • Revision ID: mbp@sourcefrog.net-20050905040803-332af983e14b1072
- help on command says "usage: bzr help"

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
 
27
27
import testsweet
28
 
from bzrlib.weave import Weave, WeaveFormatError, WeaveError
 
28
from bzrlib.weave import Weave, WeaveFormatError
29
29
from bzrlib.weavefile import write_weave, read_weave
30
 
from bzrlib.selftest import TestCase
31
30
from pprint import pformat
32
31
 
33
32
 
49
48
 
50
49
 
51
50
 
52
 
class TestBase(TestCase):
 
51
class TestBase(testsweet.TestBase):
53
52
    def check_read_write(self, k):
54
53
        """Check the weave k can be written & re-read."""
55
54
        from tempfile import TemporaryFile
112
111
        self.assertEqual(k.get(0), TEXT_0)
113
112
        self.assertEqual(k.get(1), TEXT_1)
114
113
 
 
114
        k.dump(self.TEST_LOG)
 
115
 
115
116
 
116
117
 
117
118
class InvalidAdd(TestBase):
126
127
                          ['new text!'])
127
128
 
128
129
 
129
 
class RepeatedAdd(TestBase):
130
 
    """Add the same version twice; harmless."""
131
 
    def runTest(self):
132
 
        k = Weave()
133
 
        idx = k.add('text0', [], TEXT_0)
134
 
        idx2 = k.add('text0', [], TEXT_0)
135
 
        self.assertEqual(idx, idx2)
136
 
 
137
 
 
138
 
 
139
 
class InvalidRepeatedAdd(TestBase):
140
 
    def runTest(self):
141
 
        k = Weave()
142
 
        idx = k.add('text0', [], TEXT_0)
143
 
        self.assertRaises(WeaveError,
144
 
                          k.add,
145
 
                          'text0',
146
 
                          [],
147
 
                          ['not the same text'])
148
 
        self.assertRaises(WeaveError,
149
 
                          k.add,
150
 
                          'text0',
151
 
                          [12],         # not the right parents
152
 
                          TEXT_0)
153
 
        
154
 
 
155
 
 
156
130
class InsertLines(TestBase):
157
131
    """Store a revision that adds one line to the original.
158
132
 
496
470
        self.assertEqual(k.get(0),
497
471
                         ["first line"])
498
472
 
 
473
        k.dump(self.TEST_LOG)
 
474
 
499
475
 
500
476
class DivergedIncludes(TestBase):
501
477
    """Weave with two diverged texts based on version 0.
795
771
    
796
772
 
797
773
 
 
774
def testweave():
 
775
    import testsweet
 
776
    from unittest import TestSuite, TestLoader
 
777
    import testweave
 
778
 
 
779
    tl = TestLoader()
 
780
    suite = TestSuite()
 
781
    suite.addTest(tl.loadTestsFromModule(testweave))
 
782
    
 
783
    return int(not testsweet.run_suite(suite)) # for shell 0=true
 
784
 
 
785
 
798
786
if __name__ == '__main__':
799
787
    import sys
800
 
    import unittest
801
 
    sys.exit(unittest.main())
 
788
    sys.exit(testweave())
802
789