[PATCH 03/20] tests: Use nose

Mathieu Bridon bochecha at fedoraproject.org
Wed Oct 29 12:57:01 UTC 2014


From: Mathieu Bridon <bochecha at daitauha.fr>

This simplifies dramatically the setup.py file, and we get a code
coverage report for free.
---
 .gitignore |  1 +
 setup.cfg  |  5 +++++
 setup.py   | 25 ++-----------------------
 3 files changed, 8 insertions(+), 23 deletions(-)
 create mode 100644 setup.cfg

diff --git a/.gitignore b/.gitignore
index b111b8c..630fa85 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ py-compile
 dist/
 src/rpkg.egg-info/
 /sources
+.coverage
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..fd43831
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,5 @@
+[nosetests]
+verbosity = 2
+detailed-errors = 1
+with-coverage = 1
+cover-package = pyrpkg
diff --git a/setup.py b/setup.py
index 55b44a4..3d2f378 100755
--- a/setup.py
+++ b/setup.py
@@ -1,29 +1,8 @@
 #!/usr/bin/python
 
-from setuptools import setup, Command
-try:
-    from unittest import TestLoader, TextTestRunner
-except ImportError:
-    from unittest2 import TestLoader, TextTestRunner
+from setuptools import setup
 
 
-class DiscoverTest(Command):
-    user_options = []
-
-    def run(self):
-        loader = TestLoader()
-        suite = loader.discover(start_dir='test')
-        runner = TextTestRunner()
-        result = runner.run(suite)
-        if not result.wasSuccessful():
-            sys.exit(1)
-
-    def initialize_options(self):
-        pass
-
-    def finalize_options(self):
-        pass
-
 setup(
     name="rpkg",
     version="1.28",
@@ -38,7 +17,7 @@ setup(
     scripts=['src/rpkg'],
     data_files=[('/etc/bash_completion.d', ['src/rpkg.bash']),
                 ('/etc/rpkg', ['src/rpkg.conf'])],
-    cmdclass={'test': DiscoverTest},
+    test_suite='nose.collector',
     classifiers=(
         'Development Status :: 5 - Production/Stable',
         'Environment :: Console',
-- 
2.1.0



More information about the rel-eng mailing list