X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tests%2Ftest_parse_changes.py;h=5f6d49ab38605b5c2cf2662eb6f9e2efd191067e;hb=4de9caeac056ae00c1905d430a464ae63888e3dc;hp=86291cc4d2a080b5ed7ab6439c33b0abf112e741;hpb=7b16dbdee739c035838740b7284927020033bee1;p=dak.git diff --git a/tests/test_parse_changes.py b/tests/test_parse_changes.py index 86291cc4..5f6d49ab 100755 --- a/tests/test_parse_changes.py +++ b/tests/test_parse_changes.py @@ -10,19 +10,7 @@ from daklib.dak_exceptions import InvalidDscError, ParseChangesError class ParseChangesTestCase(DakTestCase): def assertParse(self, filename, *args): - return parse_changes(fixture(filename), *args, keyrings=()) - - 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, actual_line: - if line is not None: - assertEqual(actual_line, line) + return parse_changes(fixture(filename), *args) class ParseDscTestCase(ParseChangesTestCase): def test_1(self): @@ -46,7 +34,8 @@ class ParseDscTestCase(ParseChangesTestCase): 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 @@ -56,10 +45,16 @@ class ParseDscTestCase(ParseChangesTestCase): # 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) + 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)