Loading .gitignore 0 → 100644 +11 −0 Original line number Diff line number Diff line # Python & Setuptools *.py[co] *.egg-info /.eggs/ /build/ /dist/ # Unit tests, nose, etc. .coverage .noseids /*.xml README.md 0 → 100644 +36 −0 Original line number Diff line number Diff line Setuptools-Django ================= Setuptools `test` command integration with Django unit testing. For Django applications, it is normal to run `manage.py test` to run tests. The manage.py script handles the settings environment variable and Django contains the necessary framework for testing applications. Some tools MAY want to call `setup.py test` to perform automated tests. This allows the Django framework to be invoked via manage.py as an alternative distutils 'test' command. Usage ----- Using this integration is very simple. When calling the setuptools `setup()` function, include this package in the `setup_requires` list and add the `test` class as a distutils command entrypoint: setup( [...] setup_requires = [ 'setuptools-django', ], entry_points = { 'distutils.commands': [ 'test = setuptools_django:test', ], }, [...] ) setup.cfg 0 → 100644 +24 −0 Original line number Diff line number Diff line [nosetests] verbosity = 3 tests = tests all-modules = True no-path-adjustment = True nocapture = True with-id = True with-xunit = True with-coverage = True cover-package = setuptools_django cover-inclusive = True cover-erase = True [pylint] output-format = colorized reports = no indent-string = '\t' ; would be nice to not disable bad-continuation, but for now it is bugged disable = abstract-method, bad-continuation, too-many-arguments, too-many-instance-attributes, setup.py 0 → 100755 +50 −0 Original line number Diff line number Diff line #!/usr/bin/env python import os from setuptools import setup, find_packages from setuptools_django import __version__ os.environ.setdefault('PYLINTRC', 'setup.cfg') setup( name = 'setuptools-django', version = __version__, packages = find_packages(include=['*']), extras_require = { 'dev': [ 'nose (>=1.0)', 'setuptools-lint', ], }, install_requires = [ 'setuptools', ], test_suite = '', tests_require = [ 'coverage', ], dependency_links = [ ], entry_points = { 'nose.plugins.0.10': [ 'description=util.nose_plugins:DescriptionPlugin', ] }, # Metadata author = "Dom Sekotill", author_email = "dom@kodo.org.uk", description = ( "An integration between certain setuptools (setup.py) and Django " "(manage.py) commands." ), license = "PSF", keywords = "setuptools django", url = "https://code.kodo.org.uk/dom/setuptools-django/", ) setuptools_django/__init__.py 0 → 100644 +48 −0 Original line number Diff line number Diff line __version__ = '0.1' import sys import runpy import contextlib from distutils import log from distutils.errors import DistutilsError from setuptools.command import test as test_module class test(test_module.test): """ Delegate test running to the Django generated `manage.py` script Use `runpy` to delegate running of unit tests to the Django `manage.py` script, modifying the command line arguments as necessary. This is to allow tools (or users) that expect tests to be runnable via the `setup.py` script to do so. Not all features available to the `manage.py test` subcommand are available through this command. Instead the `manage.py` command should be used directly if specific features are needed of it. """ def run_tests(self): try: with self.modify_argv(): runpy.run_module('manage', run_name='__main__', alter_sys=True) except SystemExit as exc: msg = 'Tests failed: {.code}'.format(exc) raise DistutilsError(msg) @contextlib.contextmanager def modify_argv(self): argv, orig = sys.argv, sys.argv[:] argv[1:] = ['test'] if self.verbose: argv.extend(['--verbosity', '2']) if self.test_runner: argv.extend(['--testrunner', self.test_runner]) if self.test_suite: argv.append(self.test_suite) try: yield finally: sys.argv = orig Loading
.gitignore 0 → 100644 +11 −0 Original line number Diff line number Diff line # Python & Setuptools *.py[co] *.egg-info /.eggs/ /build/ /dist/ # Unit tests, nose, etc. .coverage .noseids /*.xml
README.md 0 → 100644 +36 −0 Original line number Diff line number Diff line Setuptools-Django ================= Setuptools `test` command integration with Django unit testing. For Django applications, it is normal to run `manage.py test` to run tests. The manage.py script handles the settings environment variable and Django contains the necessary framework for testing applications. Some tools MAY want to call `setup.py test` to perform automated tests. This allows the Django framework to be invoked via manage.py as an alternative distutils 'test' command. Usage ----- Using this integration is very simple. When calling the setuptools `setup()` function, include this package in the `setup_requires` list and add the `test` class as a distutils command entrypoint: setup( [...] setup_requires = [ 'setuptools-django', ], entry_points = { 'distutils.commands': [ 'test = setuptools_django:test', ], }, [...] )
setup.cfg 0 → 100644 +24 −0 Original line number Diff line number Diff line [nosetests] verbosity = 3 tests = tests all-modules = True no-path-adjustment = True nocapture = True with-id = True with-xunit = True with-coverage = True cover-package = setuptools_django cover-inclusive = True cover-erase = True [pylint] output-format = colorized reports = no indent-string = '\t' ; would be nice to not disable bad-continuation, but for now it is bugged disable = abstract-method, bad-continuation, too-many-arguments, too-many-instance-attributes,
setup.py 0 → 100755 +50 −0 Original line number Diff line number Diff line #!/usr/bin/env python import os from setuptools import setup, find_packages from setuptools_django import __version__ os.environ.setdefault('PYLINTRC', 'setup.cfg') setup( name = 'setuptools-django', version = __version__, packages = find_packages(include=['*']), extras_require = { 'dev': [ 'nose (>=1.0)', 'setuptools-lint', ], }, install_requires = [ 'setuptools', ], test_suite = '', tests_require = [ 'coverage', ], dependency_links = [ ], entry_points = { 'nose.plugins.0.10': [ 'description=util.nose_plugins:DescriptionPlugin', ] }, # Metadata author = "Dom Sekotill", author_email = "dom@kodo.org.uk", description = ( "An integration between certain setuptools (setup.py) and Django " "(manage.py) commands." ), license = "PSF", keywords = "setuptools django", url = "https://code.kodo.org.uk/dom/setuptools-django/", )
setuptools_django/__init__.py 0 → 100644 +48 −0 Original line number Diff line number Diff line __version__ = '0.1' import sys import runpy import contextlib from distutils import log from distutils.errors import DistutilsError from setuptools.command import test as test_module class test(test_module.test): """ Delegate test running to the Django generated `manage.py` script Use `runpy` to delegate running of unit tests to the Django `manage.py` script, modifying the command line arguments as necessary. This is to allow tools (or users) that expect tests to be runnable via the `setup.py` script to do so. Not all features available to the `manage.py test` subcommand are available through this command. Instead the `manage.py` command should be used directly if specific features are needed of it. """ def run_tests(self): try: with self.modify_argv(): runpy.run_module('manage', run_name='__main__', alter_sys=True) except SystemExit as exc: msg = 'Tests failed: {.code}'.format(exc) raise DistutilsError(msg) @contextlib.contextmanager def modify_argv(self): argv, orig = sys.argv, sys.argv[:] argv[1:] = ['test'] if self.verbose: argv.extend(['--verbosity', '2']) if self.test_runner: argv.extend(['--testrunner', self.test_runner]) if self.test_suite: argv.append(self.test_suite) try: yield finally: sys.argv = orig