#!/usr/bin/env python
-import unittest
-
-import os, sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-from collections import defaultdict
+from base_test import DakTestCase
from daklib import srcformats
+from collections import defaultdict
from daklib.formats import parse_format
from daklib.dak_exceptions import UnknownFormatError
-class SourceFormatTestCase(unittest.TestCase):
+class SourceFormatTestCase(DakTestCase):
def get_rejects(self, has_vars):
has = defaultdict(lambda: 0)
has.update(has_vars)
'native_tar': 1,
})
-##
-
-class ValidateFormatTestCase(unittest.TestCase):
- def assertValid(self, format, **kwargs):
- self.fmt.validate_format(format, **kwargs)
-
- def assertInvalid(self, *args, **kwargs):
- self.assertRaises(
- UnknownFormatError,
- lambda: self.assertValid(*args, **kwargs),
- )
-
-class ValidateFormatThreeTestCase(ValidateFormatTestCase):
- fmt = srcformats.FormatThree
-
- def testValid(self):
- self.assertValid((3, 0, 'native'))
-
- def testInvalid(self):
- self.assertInvalid((1, 0))
- self.assertInvalid((0, 0))
- self.assertInvalid((3, 0, 'quilt'))
-
-class ValidateFormatThreeQuiltTestCase(ValidateFormatTestCase):
- fmt = srcformats.FormatThreeQuilt
-
- def testValid(self):
- self.assertValid((3, 0, 'quilt'))
-
- def testInvalid(self):
- self.assertInvalid((1, 0))
- self.assertInvalid((0, 0))
- self.assertInvalid((3, 0, 'native'))
-
-class FormatFromStringTestCase(unittest.TestCase):
+class FormatFromStringTestCase(DakTestCase):
def assertFormat(self, txt, klass):
self.assertEqual(srcformats.get_format_from_string(txt), klass)