[dak/master] Convert test suite to use pytest
The dbtests have not been converted (as I could not get them to run
with or without pytest).
Signed-off-by: Niels Thykier <niels@thykier.net>
---
.coveragerc | 7 +++++++
.gitignore | 2 ++
debian/control | 1 +
debian/rules | 2 +-
tests/test_all.py | 19 -------------------
tests/test_architecture.py | 0
tests/test_copy_installer.py | 0
tests/test_daklib_fstransactions.py | 0
tests/test_fix_maintainer.py | 0
tests/test_formats.py | 0
tests/test_gpg.py | 0
tests/test_imports.py | 0
tests/test_lintian.py | 0
tests/test_multiprocessing.py | 4 ++--
tests/test_packagelist.py | 0
tests/test_parse_changes.py | 0
tests/test_regexes.py | 0
tests/test_split_uploaders.py | 0
tests/test_srcformats.py | 0
19 files changed, 13 insertions(+), 22 deletions(-)
create mode 100644 .coveragerc
delete mode 100755 tests/test_all.py
mode change 100755 => 100644 tests/test_architecture.py
mode change 100755 => 100644 tests/test_copy_installer.py
mode change 100755 => 100644 tests/test_daklib_fstransactions.py
mode change 100755 => 100644 tests/test_fix_maintainer.py
mode change 100755 => 100644 tests/test_formats.py
mode change 100755 => 100644 tests/test_gpg.py
mode change 100755 => 100644 tests/test_imports.py
mode change 100755 => 100644 tests/test_lintian.py
mode change 100755 => 100644 tests/test_multiprocessing.py
mode change 100755 => 100644 tests/test_packagelist.py
mode change 100755 => 100644 tests/test_parse_changes.py
mode change 100755 => 100644 tests/test_regexes.py
mode change 100755 => 100644 tests/test_split_uploaders.py
mode change 100755 => 100644 tests/test_srcformats.py
diff --git a/.coveragerc b/.coveragerc
new file mode 100644
index 0000000..7a7ee8a
--- /dev/null
+++ b/.coveragerc
@@ -0,0 +1,7 @@
+[run]
+branch = True
+omit =
+ *_boot*.py
+ */lib/python*/*
+ */dist-packages/*
+ */tests/*
diff --git a/.gitignore b/.gitignore
index 93f38b6..b76d9fe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
*.pyc
*~
+.coverage
+cover/
web/epydoc/
web/d-i
web/deferred.html
diff --git a/debian/control b/debian/control
index f9a5e71..0e171ed 100644
--- a/debian/control
+++ b/debian/control
@@ -7,6 +7,7 @@ Build-Depends: python-all-dev,
python-debianbts,
python-ldap,
python-psycopg2,
+ python-pytest,
python-rrdtool,
python-sqlalchemy (<< 1.0),
python-yaml
diff --git a/debian/rules b/debian/rules
index 0a7139d..abf436f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -5,5 +5,5 @@
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
- tests/test_all.py
+ pytest -v
endif
diff --git a/tests/test_all.py b/tests/test_all.py
deleted file mode 100755
index 32e58ab..0000000
--- a/tests/test_all.py
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-import os
-import unittest
-
-def suite():
- suite = unittest.TestSuite()
- for _, _, files in os.walk('.'):
- for name in filter(is_test, files):
- tests = unittest.defaultTestLoader.loadTestsFromName(name[:-3])
- suite.addTests(tests)
- return suite
-
-def is_test(filename):
- return filename.startswith('test_') and filename.endswith('.py')
-
-if __name__ == "__main__":
- unittest.main(defaultTest="suite")
diff --git a/tests/test_architecture.py b/tests/test_architecture.py
old mode 100755
new mode 100644
diff --git a/tests/test_copy_installer.py b/tests/test_copy_installer.py
old mode 100755
new mode 100644
diff --git a/tests/test_daklib_fstransactions.py b/tests/test_daklib_fstransactions.py
old mode 100755
new mode 100644
diff --git a/tests/test_fix_maintainer.py b/tests/test_fix_maintainer.py
old mode 100755
new mode 100644
diff --git a/tests/test_formats.py b/tests/test_formats.py
old mode 100755
new mode 100644
diff --git a/tests/test_gpg.py b/tests/test_gpg.py
old mode 100755
new mode 100644
diff --git a/tests/test_imports.py b/tests/test_imports.py
old mode 100755
new mode 100644
diff --git a/tests/test_lintian.py b/tests/test_lintian.py
old mode 100755
new mode 100644
diff --git a/tests/test_multiprocessing.py b/tests/test_multiprocessing.py
old mode 100755
new mode 100644
index 595032f..8382c29
--- a/tests/test_multiprocessing.py
+++ b/tests/test_multiprocessing.py
@@ -7,7 +7,7 @@ from daklib.dakmultiprocessing import DakProcessPool, \
PROC_STATUS_EXCEPTION, PROC_STATUS_SIGNALRAISED
import signal
-def test_function(num, num2):
+def async_function(num, num2):
from os import kill, getpid
if num == 1:
@@ -34,7 +34,7 @@ class DakProcessPoolTestCase(DakTestCase):
p = DakProcessPool()
for s in range(3):
for j in range(4):
- p.apply_async(test_function, [s, j])
+ p.apply_async(async_function, [s, j])
p.close()
p.join()
diff --git a/tests/test_packagelist.py b/tests/test_packagelist.py
old mode 100755
new mode 100644
diff --git a/tests/test_parse_changes.py b/tests/test_parse_changes.py
old mode 100755
new mode 100644
diff --git a/tests/test_regexes.py b/tests/test_regexes.py
old mode 100755
new mode 100644
diff --git a/tests/test_split_uploaders.py b/tests/test_split_uploaders.py
old mode 100755
new mode 100644
diff --git a/tests/test_srcformats.py b/tests/test_srcformats.py
old mode 100755
new mode 100644
--
2.1.4
Reply to: