~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to testknit.py

  • Committer: Martin Pool
  • Date: 2005-06-27 02:38:05 UTC
  • mto: This revision was merged to the branch mainline in revision 852.
  • Revision ID: mbp@sourcefrog.net-20050627023805-5fdae55959ab1142
Import testsweet module adapted from bzr.

Start new test-driven development pattern, with a very trivial 
test that stores and retrieves a single text.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005 by Canonical Ltd
 
2
 
 
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.
 
7
 
 
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.
 
12
 
 
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
 
 
17
 
 
18
 
 
19
 
 
20
"""test case for knit/weave algorithm"""
 
21
 
 
22
 
 
23
from testsweet import TestBase
 
24
from knit import Knit
 
25
 
 
26
 
 
27
# texts for use in testing
 
28
TEXTS = [
 
29
    ["This is my text"], 
 
30
]
 
31
 
 
32
 
 
33
class Easy(TestBase):
 
34
    def runTest(self):
 
35
        k = Knit()
 
36
 
 
37
 
 
38
class StoreText(TestBase):
 
39
    """Store and retrieve a simple text."""
 
40
    def runTest(self):
 
41
        k = Knit()
 
42
        k.add(TEXTS[0])
 
43
        self.assertEqual(k.get(), TEXTS[0])
 
44
 
 
45
 
 
46
def testknit():
 
47
    import testsweet
 
48
    from unittest import TestSuite, TestLoader
 
49
    import testknit
 
50
 
 
51
    tl = TestLoader()
 
52
    suite = TestSuite()
 
53
    suite.addTest(tl.loadTestsFromModule(testknit))
 
54
    
 
55
    return testsweet.run_suite(suite)
 
56
 
 
57
 
 
58
if __name__ == '__main__':
 
59
    import sys
 
60
    sys.exit(testknit())
 
61