]> git.decadent.org.uk Git - dak.git/blobdiff - tests/test_srcformats.py
Split out parse_format to module-level and test it explicitly.
[dak.git] / tests / test_srcformats.py
index 834a30b4fedf7c716b7fff9e90f9a96cde186d5d..0ae182313dcd82108289db099595dead1922a0b8 100755 (executable)
@@ -105,28 +105,27 @@ class FormatTreeQuiltTestCase(SourceFormatTestCase):
 
 ##
 
-class ParseFormat(unittest.TestCase):
-    def assertFormat(self, input, expected, **kwargs):
-        self.assertEqual(
-            srcformats.SourceFormat.parse_format(input, **kwargs),
-            expected,
-        )
+class ParseFormatTestCase(unittest.TestCase):
+    def assertParse(self, format, expected):
+        self.assertEqual(srcformats.parse_format(format), expected)
 
-    def assertInvalidFormat(self, input, **kwargs):
+    def assertParseFail(self, format):
         self.assertRaises(
             UnknownFormatError,
-            lambda: srcformats.SourceFormat.parse_format(input, **kwargs),
+            lambda: srcformats.parse_format(format)
         )
 
+    def testParse(self):
+        self.assertParse('1.0', (1, 0))
+
     def testEmpty(self):
-        self.assertInvalidFormat('')
-        self.assertInvalidFormat(' ')
-        self.assertInvalidFormat('  ')
+        self.assertParseFail('')
+        self.assertParseFail(' ')
+        self.assertParseFail('  ')
 
-    def testBroken(self):
-        self.assertInvalidFormat('.0')
-        self.assertInvalidFormat('.1')
-        self.assertInvalidFormat('format')
+    def textText(self):
+        self.assertParse('1.2 (three)', (1, 2, 'three'))
+        self.assertParseFail('0.0 ()')
 
 class ParseSourceFormat(ParseFormat):
     def assertFormat(self, *args, **kwargs):
@@ -141,7 +140,7 @@ class ParseSourceFormat(ParseFormat):
         self.assertFormat('1.0', (1, 0))
 
     def testZero(self):
-        self.assertFormat('0.0', (0, 0))
+        self.assertInvalidFormat('0.0')
 
     def testNative(self):
         self.assertFormat('3.0 (native)', (3, 0, 'native'))