X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=tests%2Ftest_srcformats.py;fp=tests%2Ftest_srcformats.py;h=0ae182313dcd82108289db099595dead1922a0b8;hb=b7d36f712210b0efac983da88ae91cdd3fd7f469;hp=9c62d831bdb8a46b609e826848472fca584004f1;hpb=c9ba1a13b41a4f21b72485d9d93008f4d16f71ac;p=dak.git diff --git a/tests/test_srcformats.py b/tests/test_srcformats.py index 9c62d831..0ae18231 100755 --- a/tests/test_srcformats.py +++ b/tests/test_srcformats.py @@ -105,28 +105,27 @@ class FormatTreeQuiltTestCase(SourceFormatTestCase): ## -class ParseFormat(unittest.TestCase): - def assertFormat(self, input, expected, **kwargs): - format = srcformats.SourceFormat.parse_format(input) - self.assertEqual(format, expected) - srcformats.SourceFormat.validate_format(format, **kwargs) - - def assertInvalidFormat(self, input, **kwargs): - try: - format = srcformats.SourceFormat.parse_format(input) - srcformats.SourceFormat.validate_format(format, **kwargs) - except UnknownFormatError: - return +class ParseFormatTestCase(unittest.TestCase): + def assertParse(self, format, expected): + self.assertEqual(srcformats.parse_format(format), expected) + + def assertParseFail(self, format): + self.assertRaises( + UnknownFormatError, + lambda: srcformats.parse_format(format) + ) + + def testParse(self): + self.assertParse('1.0', (1, 0)) def testEmpty(self): - self.assertInvalidFormat('') - self.assertInvalidFormat(' ') - self.assertInvalidFormat(' ') - - def testBroken(self): - self.assertInvalidFormat('.0') - self.assertInvalidFormat('.1') - self.assertInvalidFormat('format') + self.assertParseFail('') + self.assertParseFail(' ') + self.assertParseFail(' ') + + def textText(self): + self.assertParse('1.2 (three)', (1, 2, 'three')) + self.assertParseFail('0.0 ()') class ParseSourceFormat(ParseFormat): def assertFormat(self, *args, **kwargs):