def assertParse(self, filename, *args):
return parse_changes(fixture(filename), *args)
- def assertFails(self, filename, line=None, *args):
- try:
- self.assertParse(filename, *args)
- self.fail('%s was not recognised as invalid' % filename)
- except ParseChangesError:
- pass
- except GpgException:
- pass
- except InvalidDscError as actual_line:
- if line is not None:
- assertEqual(actual_line, line)
-
class ParseDscTestCase(ParseChangesTestCase):
def test_1(self):
self.assertParse('dsc/1.dsc', -1, 1)
def test_4(self):
# No blank lines at all
- self.assertFails('dsc/4.dsc', -1, 1)
+ with self.assertRaises(GpgException):
+ self.assertParse('dsc/4.dsc', -1, 1)
def test_5(self):
# Extra blank line before signature body
# Extra blank line after signature header
self.assertParse('dsc/6.dsc', -1, 1)
+ def test_7(self):
+ # Blank file is an invalid armored GPG file
+ with self.assertRaises(GpgException):
+ self.assertParse('dsc/7.dsc', -1, 1)
+
+ def test_8(self):
+ # No armored contents
+ with self.assertRaisesRegexp(ParseChangesError, "Empty changes"):
+ self.assertParse('dsc/8.dsc', -1, 1)
+
+ def test_9(self):
+ changes = self.assertParse('dsc/9.dsc', -1, 1)
+ self.assert_(changes['question'] == 'Is this a bug?')
+ self.failIf(changes.get('this'))
+
class ParseChangesTestCase(ParseChangesTestCase):
def test_1(self):
# Empty changes
- self.assertFails('changes/1.changes', 5, -1)
+ with self.assertRaises(GpgException):
+ self.assertParse('changes/1.changes', 1)
def test_2(self):
changes = self.assertParse('changes/2.changes', -1)
)
self.failIf(changes.get('you'))
- def test_4(self):
- changes = self.assertParse('changes/two-beginnings.changes', -1, 1)
- self.assert_(changes['question'] == 'Is this a bug?')
- self.failIf(changes.get('this'))
-
if __name__ == '__main__':
unittest.main()