Permalink
Browse files

magic-removal: Removed legacy init_minimal calls. Unit test framework…

… works again.

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2387 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
adrianholovaty committed Feb 25, 2006
1 parent 39e4e8c commit 65dc8f000baa35ec4518e5a6ff41a1b0d714561c
Showing with 17 additions and 18 deletions.
  1. +10 −9 django/core/management.py
  2. +7 −9 tests/runtests.py
View
@@ -297,15 +297,13 @@ def get_sql_initial_data(app):
output = [] output = []
app_models = get_models(app) app_models = get_models(app)
app_label = app_models[0]._meta.app_label
output.append(_get_packages_insert(app_label))
app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql')) app_dir = os.path.normpath(os.path.join(os.path.dirname(app.__file__), 'sql'))
for klass in app_models: for klass in app_models:
opts = klass._meta opts = klass._meta
# Add custom SQL, if it's available. # Add custom SQL, if it's available.
# FIXME: This probably needs changing # TODO: This probably needs changing
sql_files = [os.path.join(app_dir, opts.module_name + '.' + settings.DATABASE_ENGINE + '.sql'), sql_files = [os.path.join(app_dir, opts.module_name + '.' + settings.DATABASE_ENGINE + '.sql'),
os.path.join(app_dir, opts.module_name + '.sql')] os.path.join(app_dir, opts.module_name + '.sql')]
for sql_file in sql_files: for sql_file in sql_files:
@@ -314,11 +312,14 @@ def get_sql_initial_data(app):
output.append(fp.read()) output.append(fp.read())
fp.close() fp.close()
# Content types. # TODO: This is temporarily commented out until we come up
output.append(_get_contenttype_insert(opts)) # with a better way of letting people initialize content types and
# Permissions. # permissions.
for codename, name in _get_all_permissions(opts): # # Content types.
output.append(_get_permission_insert(name, codename, opts)) # output.append(_get_contenttype_insert(opts))
# # Permissions.
# for codename, name in _get_all_permissions(opts):
# output.append(_get_permission_insert(name, codename, opts))
return output return output
get_sql_initial_data.help_doc = "Prints the initial INSERT SQL statements for the given app name(s)." get_sql_initial_data.help_doc = "Prints the initial INSERT SQL statements for the given app name(s)."
get_sql_initial_data.args = APP_ARGS get_sql_initial_data.args = APP_ARGS
@@ -1164,7 +1165,7 @@ def execute_from_command_line(action_mapping=DEFAULT_ACTION_MAPPING):
action_mapping[action](username, email, password) action_mapping[action](username, email, password)
elif action == 'shell': elif action == 'shell':
action_mapping[action](options.plain is True) action_mapping[action](options.plain is True)
elif action in ('init', 'init-minimal', 'validate'): elif action in ('init', 'validate'):
action_mapping[action]() action_mapping[action]()
elif action == 'inspectdb': elif action == 'inspectdb':
try: try:
View
@@ -89,7 +89,7 @@ def run_tests(self):
test_models = [] test_models = []
else: else:
run_othertests = not self.which_tests run_othertests = not self.which_tests
if self.which_tests: if self.which_tests:
# Only run the specified tests. # Only run the specified tests.
bad_models = [m for m in self.which_tests if m not in test_models] bad_models = [m for m in self.which_tests if m not in test_models]
@@ -133,8 +133,6 @@ def run_tests(self):
# Initialize the test database. # Initialize the test database.
cursor = connection.cursor() cursor = connection.cursor()
self.output(1, "Initializing test database")
management.init_minimal()
# Run the tests for each test model. # Run the tests for each test model.
self.output(1, "Running app tests") self.output(1, "Running app tests")
@@ -146,7 +144,7 @@ def run_tests(self):
except Exception, e: except Exception, e:
log_error(model_name, "Error while importing", ''.join(traceback.format_exception(*sys.exc_info())[1:])) log_error(model_name, "Error while importing", ''.join(traceback.format_exception(*sys.exc_info())[1:]))
continue continue
if not getattr(mod, 'error_log', None): if not getattr(mod, 'error_log', None):
# Model is not marked as an invalid model # Model is not marked as an invalid model
self.output(1, "%s model: Installing" % model_name) self.output(1, "%s model: Installing" % model_name)
@@ -162,21 +160,21 @@ def run_tests(self):
runner = DjangoDoctestRunner(verbosity_level=verbosity_level, verbose=False) runner = DjangoDoctestRunner(verbosity_level=verbosity_level, verbose=False)
self.output(1, "%s model: Running tests" % model_name) self.output(1, "%s model: Running tests" % model_name)
runner.run(dtest, clear_globs=True, out=sys.stdout.write) runner.run(dtest, clear_globs=True, out=sys.stdout.write)
else: else:
# Check that model known to be invalid is invalid for the right reasons. # Check that model known to be invalid is invalid for the right reasons.
self.output(1, "%s model: Validating" % model_name) self.output(1, "%s model: Validating" % model_name)
from cStringIO import StringIO from cStringIO import StringIO
s = StringIO() s = StringIO()
count = management.get_validation_errors(s, mod) count = management.get_validation_errors(s, mod)
s.seek(0) s.seek(0)
error_log = s.read() error_log = s.read()
actual = error_log.split('\n') actual = error_log.split('\n')
expected = mod.error_log.split('\n') expected = mod.error_log.split('\n')
unexpected = [err for err in actual if err not in expected] unexpected = [err for err in actual if err not in expected]
missing = [err for err in expected if err not in actual] missing = [err for err in expected if err not in actual]
if unexpected or missing: if unexpected or missing:
unexpected_log = '\n'.join(unexpected) unexpected_log = '\n'.join(unexpected)
missing_log = '\n'.join(missing) missing_log = '\n'.join(missing)

0 comments on commit 65dc8f0

Please sign in to comment.