Package moap :: Package test :: Module test_util_ctags
[hide private]
[frames] | no frames]

Source Code for Module moap.test.test_util_ctags

 1  # -*- Mode: Python; test-case-name: moap.test.test_doap_doap -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3   
 4  import os 
 5   
 6  from common import unittest 
 7   
 8  from moap.util import ctags 
 9   
10 -class TestTag(unittest.TestCase):
11 - def setUp(self):
12 self.tag = ctags.Tag()
13
14 - def testRepr(self):
15 self.failUnless(repr(self.tag))
16
17 - def testParse(self):
18 self.tag.parse('diff\tmoap/vcs/cvs.py\t/^ def diff(self, path):$/;"\tm\tline:98\tlanguage:Python\tclass:CVS') 19 self.assertEquals(self.tag.name, "diff") 20 self.assertEquals(self.tag.file, "moap/vcs/cvs.py") 21 self.assertEquals(self.tag.line, 98) 22 self.assertEquals(self.tag.language, 'Python') 23 self.assertEquals(self.tag.klazz, 'CVS')
24
25 - def test281(self):
26 # in moap.util.ctags, the tagMatcher originally had non-spaces for 27 # the first column; ticket 281 has a space in the first column. 28 self.tag.parse('line operator =\t/home/murrayc/svn/gnome220/branches/glom-1-6/glom/libglom/data_structure/field.cc\t/^Field& Field::operator=(const Field& src)$/;"\tf\tline:58\tlanguage:C++\tclass:Glom::Field\tsignature:(const Field& src)')
29
30 -class TestCTags(unittest.TestCase):
31 - def setUp(self):
32 file = os.path.join(os.path.dirname(__file__), 'ctags', 'tags') 33 self.ctags = ctags.CTags() 34 self.ctags.addFile(file)
35
36 - def testGetManyTags(self):
37 tags = self.ctags.getTags('moap/vcs/cvs.py', 93, 11) 38 self.assertEquals(tags[0].name, 'commit') 39 self.assertEquals(tags[1].name, 'diff')
40
41 - def testGetBeforeFirstTag(self):
42 # asking for tags before there are any should return no tags 43 tags = self.ctags.getTags('moap/vcs/cvs.py', 5, 6) 44 self.failIf(tags)
45
46 - def testGetWithFirstTag(self):
47 # asking for tags before and in first tag should give first tag 48 tags = self.ctags.getTags('moap/vcs/cvs.py', 15, 6) 49 self.assertEquals(len(tags), 1) 50 self.assertEquals(tags[0].name, 'detect')
51
52 - def testGetTagBeforeTagLine(self):
53 tags = self.ctags.getTags('moap/vcs/cvs.py', 15) 54 self.failIf(tags)
55
56 - def testGetTagOnTagLine(self):
57 tags = self.ctags.getTags('moap/vcs/cvs.py', 16) 58 self.assertEquals(len(tags), 1) 59 self.assertEquals(tags[0].name, 'detect')
60
61 - def testGetTagAfterTagLine(self):
62 tags = self.ctags.getTags('moap/vcs/cvs.py', 17) 63 self.assertEquals(len(tags), 1) 64 self.assertEquals(tags[0].name, 'detect')
65
66 - def testGetLastTwo(self):
67 # update starts on 106 68 tags = self.ctags.getTags('moap/vcs/cvs.py', 105, 2) 69 self.assertEquals(len(tags), 2) 70 self.assertEquals(tags[0].name, 'diff') 71 self.assertEquals(tags[1].name, 'update')
72
73 - def testGetLastTag(self):
74 tags = self.ctags.getTags('moap/vcs/cvs.py', 106) 75 self.assertEquals(len(tags), 1) 76 self.assertEquals(tags[0].name, 'update')
77
78 -class TestCTagsFromString(unittest.TestCase):
79 - def testFromEmptyString(self):
80 self.ctags = ctags.CTags() 81 self.ctags.addString('')
82
83 - def testFromString(self):
84 self.ctags = ctags.CTags() 85 self.ctags.addString('!_TAG_')
86
87 - def testFromWrongString(self):
88 self.ctags = ctags.CTags() 89 self.assertRaises(KeyError, self.ctags.addString, 'wrongtype')
90