]> git.decadent.org.uk Git - dak.git/blob - tests/test_lintian.py
Move lintian parsing to daklib.lintian and add tests.
[dak.git] / tests / test_lintian.py
1 #!/usr/bin/env python
2
3 from base_test import DakTestCase
4
5 import unittest
6
7 from daklib.lintian import parse_lintian_output
8
9 class ParseLintianTestCase(DakTestCase):
10     def assertParse(self, output, expected):
11         self.assertEqual(
12             list(parse_lintian_output(output)),
13             expected,
14         )
15
16     def testSimple(self):
17         self.assertParse(
18             'W: pkgname: some-tag path/to/file',
19             [('W', 'pkgname', 'some-tag', 'path/to/file')],
20         )
21
22         self.assertParse('', [])
23         self.assertParse('\n\n', [])
24         self.assertParse('dummy error test', [])
25
26     def testBinaryNoDescription(self):
27         self.assertParse(
28             'W: pkgname: some-tag',
29             [('W', 'pkgname', 'some-tag', '')],
30         )
31
32     def testSource(self):
33         self.assertParse(
34             'W: pkgname source: some-tag',
35             [('W', 'pkgname source', 'some-tag', '')]
36         )
37
38     def testSourceNoDescription(self):
39         self.assertParse(
40             'W: pkgname source: some-tag path/to/file',
41             [('W', 'pkgname source', 'some-tag', 'path/to/file')]
42         )
43
44 if __name__ == '__main__':
45     unittest.main()