[dak/master 03/23] Make all tests use DakTestCase.
Signed-off-by: Chris Lamb <lamby@debian.org>
---
tests/test_formats.py | 12 +++++++-----
tests/test_regexes.py | 9 +++------
tests/test_srcformats.py | 12 ++++--------
3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/tests/test_formats.py b/tests/test_formats.py
index 1ae6860..a897eeb 100755
--- a/tests/test_formats.py
+++ b/tests/test_formats.py
@@ -1,14 +1,13 @@
#!/usr/bin/env python
-import unittest
+from base_test import DakTestCase
-import os, sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+import unittest
from daklib.formats import parse_format, validate_changes_format
from daklib.dak_exceptions import UnknownFormatError
-class ParseFormatTestCase(unittest.TestCase):
+class ParseFormatTestCase(DakTestCase):
def assertParse(self, format, expected):
self.assertEqual(parse_format(format), expected)
@@ -30,7 +29,7 @@ class ParseFormatTestCase(unittest.TestCase):
self.assertParse('1.2 (three)', (1, 2, 'three'))
self.assertParseFail('0.0 ()')
-class ValidateChangesFormat(unittest.TestCase):
+class ValidateChangesFormat(DakTestCase):
def assertValid(self, changes, field='files'):
validate_changes_format(changes, field)
@@ -56,3 +55,6 @@ class ValidateChangesFormat(unittest.TestCase):
def testFilesField(self):
self.assertInvalid((1, 7), field='notfiles')
self.assertValid((1, 8), field='notfiles')
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/test_regexes.py b/tests/test_regexes.py
index 766e73e..8faf9a0 100755
--- a/tests/test_regexes.py
+++ b/tests/test_regexes.py
@@ -1,13 +1,10 @@
#!/usr/bin/env python
-import unittest
-
-import os, sys
-sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+from base_test import DakTestCase
from daklib import regexes
-class re_single_line_field(unittest.TestCase):
+class re_single_line_field(DakTestCase):
MATCH = regexes.re_single_line_field.match
def testSimple(self):
@@ -32,7 +29,7 @@ class re_single_line_field(unittest.TestCase):
self.assertEqual(self.MATCH('Foo::bar').groups(), ('Foo', ':bar'))
self.assertEqual(self.MATCH('Foo: :bar').groups(), ('Foo', ':bar'))
-class re_parse_lintian(unittest.TestCase):
+class re_parse_lintian(DakTestCase):
MATCH = regexes.re_parse_lintian.match
def testBinary(self):
diff --git a/tests/test_srcformats.py b/tests/test_srcformats.py
index 4ecaf8b..fa6f3b3 100755
--- a/tests/test_srcformats.py
+++ b/tests/test_srcformats.py
@@ -1,17 +1,13 @@
#!/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)
@@ -104,7 +100,7 @@ class FormatTreeQuiltTestCase(SourceFormatTestCase):
'native_tar': 1,
})
-class FormatFromStringTestCase(unittest.TestCase):
+class FormatFromStringTestCase(DakTestCase):
def assertFormat(self, txt, klass):
self.assertEqual(srcformats.get_format_from_string(txt), klass)
--
1.6.3.3
Reply to: