3 from base_test import DakTestCase
5 from daklib import regexes
7 class re_single_line_field(DakTestCase):
8 MATCH = regexes.re_single_line_field.match
11 self.assertEqual(self.MATCH('Foo: bar').groups(), ('Foo', 'bar'))
13 def testLeadingWhitespace(self):
14 self.assertEqual(self.MATCH(' Foo: bar'), None)
16 def testTrailingWhitespace(self):
17 self.assertEqual(self.MATCH('Foo: bar \n').groups(), ('Foo', 'bar '))
19 def testMiddleWhitespace(self):
20 self.assertEqual(self.MATCH('Foo: bar').groups(), ('Foo', 'bar'))
21 self.assertEqual(self.MATCH('Foo : bar').groups(), ('Foo', 'bar'))
22 self.assertEqual(self.MATCH('Foo \n:\n bar').groups(), ('Foo', 'bar'))
23 self.assertEqual(self.MATCH('Foo:bar').groups(), ('Foo', 'bar'))
26 self.assertEqual(self.MATCH('Foo: :').groups(), ('Foo', ':'))
27 self.assertEqual(self.MATCH('Foo: ::').groups(), ('Foo', '::'))
28 self.assertEqual(self.MATCH(': ::').groups(), ('', '::'))
29 self.assertEqual(self.MATCH('Foo::bar').groups(), ('Foo', ':bar'))
30 self.assertEqual(self.MATCH('Foo: :bar').groups(), ('Foo', ':bar'))
32 class re_parse_lintian(DakTestCase):
33 MATCH = regexes.re_parse_lintian.match
37 self.MATCH('W: pkgname: some-tag path/to/file').groupdict(),
42 'description': 'path/to/file',
46 def testBinaryNoDescription(self):
48 self.MATCH('W: pkgname: some-tag').groupdict(),
59 self.MATCH('W: pkgname source: some-tag').groupdict(),
62 'package': 'pkgname source',
68 def testSourceNoDescription(self):
70 self.MATCH('W: pkgname source: some-tag path/to/file').groupdict(),
73 'package': 'pkgname source',
75 'description': 'path/to/file',
79 if __name__ == '__main__':