testing: Don't create DB twice for backend.

In backend tests, only call generate-fixtures when --generate-fixtures
is explicitly passed or is_template_database_current() returns False.

We don't need to flush cache for backend tests because we bounce the key
prefix used to create cache keys before running every test
This commit is contained in:
Umair Khan 2017-04-13 14:06:48 +05:00
parent e23b660ccc
commit bf713bcdfe
1 changed files with 4 additions and 7 deletions

View File

@ -172,10 +172,9 @@ if __name__ == "__main__":
action="store_true",
default=False,
help="Show detailed output")
parser.add_option('--no-generate-fixtures', action="store_false", default=True,
parser.add_option('--generate-fixtures', action="store_true", default=False,
dest="generate_fixtures",
help=("Reduce running time by not calling generate-fixtures. "
"This may cause spurious failures for some tests."))
help=("Force a call to generate-fixtures."))
parser.add_option('--report-slow-tests', dest='report_slow_tests',
action="store_true",
default=False,
@ -283,11 +282,9 @@ if __name__ == "__main__":
# files, since part of setup is importing the models for all applications in INSTALLED_APPS.
django.setup()
if options.generate_fixtures:
if options.generate_fixtures or not is_template_database_current():
generate_fixtures_command = [os.path.join(TOOLS_DIR, 'setup', 'generate-fixtures')]
if not is_template_database_current():
generate_fixtures_command.append('--force')
generate_fixtures_command.append('--force')
subprocess.call(generate_fixtures_command)
TestRunner = get_runner(settings)