Index: setup.py
===================================================================
--- setup.py	(revision 06d73287ec3c85549d37606cc0f2cb35962feafd)
+++ setup.py	(revision a0940416a80f2ac3b297b4ee91531abf54837d7e)
@@ -38,5 +38,5 @@
 
 import pkg_resources
-from setuptools.command import develop, install, sdist, bdist_egg, easy_install
+from setuptools.command import develop, install, sdist, bdist_egg, easy_install, test
 from setuptools import setup, find_packages, findall
 
@@ -52,4 +52,5 @@
                    "https://github.com/collective/icalendar/tarball/6f899869d462a23d0ebd3f54fb237e8670242bc4#egg=icalendar-3.0"]
 
+DEVELOP_REQUIRES = ['pojson', 'termcolor']
 
 if sys.platform == 'linux2':
@@ -207,7 +208,10 @@
 
     def run(self):
-
         # dependencies, links, etc...
         develop.develop.run(self)
+
+        env = pkg_resources.Environment()
+        easy_install.main(DEVELOP_REQUIRES)
+        env.scan()
 
         local = 'etc/indico.conf'
@@ -281,5 +285,5 @@
         open(filePath, 'w').write(fdata)
 
-class test_indico(Command):
+class test_indico(test.test):
     """
     Test command for Indico
@@ -287,5 +291,5 @@
 
     description = "Test Suite Framework"
-    user_options = [('specify=', None, "Use nosetests style (file.class:testcase)"),
+    user_options = test.test.user_options + [('specify=', None, "Use nosetests style (file.class:testcase)"),
                     ('coverage', None, "Output coverage report in html"),
                     ('unit', None, "Run only Unit tests"),
@@ -328,25 +332,14 @@
     xml = False
 
-    def initialize_options(self):
-        pass
+    def _wrap(self, func, *params):
+        def wrapped():
+            self.res = func(*params)
+        self.with_project_on_sys_path(wrapped)
+        return self.res
 
     def finalize_options(self):
-        pass
-
-    def run(self):
-
-        if not self.checkTestPackages():
-            print "Please install those missing packages before launching the tests again"
-            sys.exit(-1)
-
-        #missing jars will be downloaded automatically
-        if not self.checkTestJars():
-            print "Some jars could not be downloaded. Please download the missing jars manually"
-            sys.exit(-1)
-
-        from indico.tests import TestManager, TEST_RUNNERS
         testsToRun = []
 
-        allTests = TEST_RUNNERS.keys()
+        allTests = ['unit', 'functional']
 
         for testType in allTests:
@@ -359,5 +352,19 @@
         if testsToRun == []:
             testsToRun = allTests
-
+        self.testsToRun = testsToRun
+
+    def run(self):
+
+        if self.distribution.install_requires:
+            self.distribution.fetch_build_eggs(self.distribution.install_requires)
+        if self.distribution.tests_require:
+            self.distribution.fetch_build_eggs(self.distribution.tests_require)
+
+        from indico.tests import TestManager
+
+        #missing jars will be downloaded automatically
+        if not self._wrap(self.checkTestJars):
+            print "Some jars could not be downloaded. Please download the missing jars manually"
+            sys.exit(-1)
 
         options = {'silent': self.silent,
@@ -377,26 +384,7 @@
 
         manager = TestManager()
-
-        result = manager.main(testsToRun, options)
+        result = self._wrap(manager.main, self.testsToRun, options)
 
         sys.exit(result)
-
-    def checkTestPackages(self):
-        packagesList = ['figleaf',
-                        'nose>=0.11',
-                        'rednose',
-                        'selenium',
-                        'twill']
-        validPackages = True
-
-        for package in packagesList:
-            try:
-                pkg_resources.require(package)
-            except pkg_resources.DistributionNotFound:
-                print """
-%s not found! Please install it.
-i.e. try 'easy_install %s'""" % (package, package)
-                validPackages = False
-        return validPackages
 
     def checkTestJars(self):
@@ -626,4 +614,5 @@
           namespace_packages = ['indico', 'indico.ext'],
           install_requires = _getInstallRequires(),
+          tests_require = ['nose', 'rednose', 'twill', 'selenium', 'figleaf'],
           data_files = dataFiles,
           dependency_links = DEPENDENCY_URLS
