Move run_tornado import into runserver function because its imports needs settings (new in Django 1.6).

This commit is contained in:
Norman Jäckel 2013-11-10 22:04:35 +01:00
parent d2309cbe49
commit c4850e4b19
2 changed files with 4 additions and 2 deletions

View File

@ -23,7 +23,6 @@ from openslides.utils.main import (
setup_django_settings_module, setup_django_settings_module,
start_browser, start_browser,
write_settings) write_settings)
from openslides.utils.tornado_webserver import run_tornado
def main(): def main():
@ -231,6 +230,9 @@ def runserver(settings, args):
if args.start_browser: if args.start_browser:
browser_url = get_browser_url(address=args.address, port=port) browser_url = get_browser_url(address=args.address, port=port)
start_browser(browser_url) start_browser(browser_url)
# Now the settings is available and the function can be imported.
from openslides.utils.tornado_webserver import run_tornado
run_tornado(args.address, port, not args.no_reload) run_tornado(args.address, port, not args.no_reload)

View File

@ -131,7 +131,7 @@ class TestOtherFunctions(TestCase):
mock_runserver.assert_called_with(None, mock_args) mock_runserver.assert_called_with(None, mock_args)
@patch('openslides.__main__.get_port') @patch('openslides.__main__.get_port')
@patch('openslides.__main__.run_tornado') @patch('openslides.utils.tornado_webserver.run_tornado')
@patch('openslides.__main__.start_browser') @patch('openslides.__main__.start_browser')
def test_runserver(self, mock_start_browser, mock_run_tornado, mock_get_port): def test_runserver(self, mock_start_browser, mock_run_tornado, mock_get_port):
mock_get_port.return_value = 8000 mock_get_port.return_value = 8000