Permalink
Browse files

Old files deleted

  • Loading branch information...
1 parent 1d2ab48 commit f24e27ee4c0903046cace316599dbf0cb6c2bf99 Martin Rusev committed Sep 10, 2010
View
@@ -1,4 +1,4 @@
*.pyc
-.project
-.pydevproject
+*.project
+*.pydevproject
View
68 README
@@ -1,68 +0,0 @@
-django-better-tests
-=======================
-
-This is a collection of commands for your django projects, that separates
-test database creation from the actual test run
-
-
-The advantages of using this over 'manage.py test' is that you control both
-the database creation and the test run
-
-------------
-Installation
-------------
-
-1. Either download the tarball and run ``python setup.py install``,
-
-2. Add ``django_better_tests`` to your INSTALLED_APPS in settings.py:
-
- INSTALLED_APPS = (
- ...
- 'django_better_tests',
- ...
- )
-
-
-3. Add test database details in settings.py
-
- DATABASES = {
- 'default': {
- 'ENGINE': '',
-
- },
- 'test': {
- 'ENGINE': '',
- 'NAME': 'test_database',
- }
- }
-
-
-4. Then set TEST_RUNNER in settings.py::
-
- TEST_RUNNER = 'django_better_tests.NoseTestSuiteRunner'
-
-
------
-Usage
------
-
-Once installed, using the new test suite runner replacement is easy. Create your test database with::
-
-
- python manage.py create_test_db
-
-After that run your tests with
-
- python manage.py quick_test
-
-
-And finally if you want destroy the test database with
-
- python manage.py destroy_test_db
-
-------------
-Requirements
-------------
-
-Django 1.2+
-
View
No changes.
View
No changes.
No changes.
@@ -1,19 +0,0 @@
-from django.core.management.base import BaseCommand
-from optparse import make_option
-import sys
-from django.db import connection
-from django.conf import settings
-from django.core.management import call_command
-
-class Command(BaseCommand):
- help = 'Creates the test db'
-
-
- def handle(self, *args, **options):
- connection.creation.create_test_db(verbosity = 1, autoclobber=False)
- call_command('migrate', database='test', app=None,
- target=None, skip=False, merge=False, backwards=False, fake=False, db_dry_run=False, show_list=False)
-
- connection.close()
-
-
@@ -1,14 +0,0 @@
-from django.core.management.base import BaseCommand
-from optparse import make_option
-import sys
-from django.db import connection
-from django.conf import settings
-
-class Command(BaseCommand):
- help = 'Destroys the test db'
-
-
- def handle(self, *args, **options):
- test_db = settings.DATABASES['default']['NAME']
- connection.creation.destroy_test_db(test_db, verbosity = 1)
-
@@ -1,42 +0,0 @@
-from django.core.management.base import BaseCommand
-from optparse import make_option
-import sys
-
-class Command(BaseCommand):
- option_list = BaseCommand.option_list + (
- make_option('--noinput', action='store_false', dest='interactive', default=True,
- help='Tells Django to NOT prompt the user for input of any kind.'),
- make_option('--failfast', action='store_true', dest='failfast', default=False,
- help='Tells Django to stop running the test suite after first failed test.')
- )
- help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.'
- args = '[appname ...]'
-
- requires_model_validation = False
-
- def handle(self, *test_labels, **options):
- from django.conf import settings
-
- verbosity = int(options.get('verbosity', 1))
- interactive = options.get('interactive', True)
- failfast = options.get('failfast', False)
-
-
- test_module = __import__('tests.testrunner', {}, {}, 'NoseTestSuiteRunner')
- TestRunner = getattr(test_module, 'NoseTestSuiteRunner')
-
- if hasattr(TestRunner, 'func_name'):
- # Pre 1.2 test runners were just functions,
- # and did not support the 'failfast' option.
- import warnings
- warnings.warn(
- 'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',
- PendingDeprecationWarning
- )
- failures = TestRunner(test_labels, verbosity=verbosity, interactive=interactive)
- else:
- test_runner = TestRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
- failures = test_runner.run_tests(test_labels)
-
- if failures:
- sys.exit(bool(failures))
View
@@ -1,100 +0,0 @@
-import os
-import sys
-from django.conf import settings
-from django.core.management.base import BaseCommand
-from django.test.simple import DjangoTestSuiteRunner
-from django.db import connection
-
-
-import nose.core
-
-from django_nose.plugin import ResultPlugin
-
-try:
- any
-except NameError:
- def any(iterable):
- for element in iterable:
- if element:
- return True
- return False
-
-# This is a table of Django's "manage.py test" options which
-# correspond to nosetests options with a different name:
-OPTION_TRANSLATION = {'--failfast': '-x'}
-
-
-class NoseTestSuiteRunner(DjangoTestSuiteRunner):
-
- def run_suite(self, nose_argv):
- result_plugin = ResultPlugin()
- nose.core.TestProgram(argv=nose_argv, exit=False,
- addplugins=[result_plugin])
- return result_plugin.result
-
- def run_tests(self, test_labels, extra_tests=None):
- """
- Run the unit tests for all the test names in the provided list.
-
- Test names specified may be file or module names, and may optionally
- indicate the test case to run by separating the module or file name
- from the test case name with a colon. Filenames may be relative or
- absolute. Examples:
-
- runner.run_tests('test.module')
- runner.run_tests('another.test:TestCase.test_method')
- runner.run_tests('a.test:TestCase')
- runner.run_tests('/path/to/test/file.py:test_function')
-
- Returns the number of tests that failed.
- """
-
- settings.DEBUG = False
-
- self.setup_test_environment()
-
-
- settings.DATABASES['default']['SUPPORTS_TRANSACTIONS'] = connection.creation._rollback_works()
- settings.DATABASES['test']['SUPPORTS_TRANSACTIONS'] = connection.creation._rollback_works()
-
-
- nose_argv = ['nosetests', '--verbosity', str(self.verbosity)]
-
- if hasattr(settings, 'NOSE_ARGS'):
- nose_argv.extend(settings.NOSE_ARGS)
-
- # Skip over 'manage.py test' and any arguments handled by django.
- django_opts = ['--noinput']
- for opt in BaseCommand.option_list:
- django_opts.extend(opt._long_opts)
- django_opts.extend(opt._short_opts)
-
- nose_argv.extend(OPTION_TRANSLATION.get(opt, opt)
- for opt in sys.argv[2:]
- if not any(opt.startswith(d) for d in django_opts))
-
- if self.verbosity >= 1:
- print ' '.join(nose_argv)
-
-
- result = self.run_suite(nose_argv)
-
- self.teardown_test_environment()
- # suite_result expects the suite as the first argument. Fake it.
- return self.suite_result({}, result)
-
-
-def _get_options():
- """Return all nose options that don't conflict with django options."""
- cfg_files = nose.core.all_config_files()
- manager = nose.core.DefaultPluginManager()
- config = nose.core.Config(env=os.environ, files=cfg_files, plugins=manager)
- options = config.getParser().option_list
- django_opts = [opt.dest for opt in BaseCommand.option_list] + ['version']
- return tuple(o for o in options if o.dest not in django_opts and
- o.action != 'help')
-
-
-# Replace the builtin command options with the merged django/nose options.
-NoseTestSuiteRunner.options = _get_options()
-NoseTestSuiteRunner.__test__ = False

0 comments on commit f24e27e

Please sign in to comment.