From f68a392250d3602809b0e1840840c3e2e811df2e Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Mon, 20 Jun 2016 22:49:45 -0400 Subject: [PATCH] Run django.setup() after coverage.start() in tests to fix coverage report. Fixes #1007. --- tools/test-backend | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/test-backend b/tools/test-backend index c2ff7ccd70..74961ef9b8 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -25,7 +25,6 @@ if __name__ == "__main__": os.environ['DJANGO_SETTINGS_MODULE'] = 'zproject.test_settings' # "-u" uses unbuffered IO, which is important when wrapping it in subprocess os.environ['PYTHONUNBUFFERED'] = 'y' - django.setup() parser = optparse.OptionParser() parser.add_option('--nonfatal-errors', action="store_false", default=True, @@ -63,6 +62,10 @@ if __name__ == "__main__": prof = cProfile.Profile() prof.enable() + # setup() needs to be called after coverage is started to get proper coverage reports of model + # files, since part of setup is importing the models for all applications in INSTALLED_APPS. + django.setup() + subprocess.call(os.path.join(TOOLS_DIR, 'setup', 'generate-fixtures')) TestRunner = get_runner(settings)