Source

django-autocomplete / setup.py

Diff from to
-from setuptools import setup
+import os
+import sys
+
+from setuptools import setup, Command
 import pkg_resources
 import autocomplete
 
 
+class test(Command):
+    description = 'Run the test suite'
+
+    user_options = [
+        ('settings=', 's',
+            'Run the test suite with the specified settings module')
+    ]
+
+    def initialize_options(self):
+        self.settings = None
+
+    def finalize_options(self):
+        if self.settings is None:
+            self.settings = 'test_project.settings'
+
+    def run(self):
+        from django.core.management import call_command
+
+        os.environ['DJANGO_SETTINGS_MODULE'] = self.settings
+        tests_dir = os.path.join(os.path.dirname(__file__), 'tests')
+        sys.path.append(tests_dir)
+
+        call_command('test', 'testapp')
+
+
+
+
 def get_metadata_version():
     """
     Tries to get the version from the django_autocomplete.egg-info directory.
         'Programming Language :: Python',
         'Topic :: Utilities'
     ],
+    cmdclass = {'test': test},
 )