unify mocking of tornado_settings

ensures that everywhere we access settings, it's the same dict
and not a copy
This commit is contained in:
Min RK
2018-02-28 15:09:25 +01:00
parent e025d58f6e
commit 015df7e060
5 changed files with 24 additions and 29 deletions

View File

@@ -518,7 +518,6 @@ def test_never_spawn(app, no_patience, never_spawn):
@mark.gen_test
def test_bad_spawn(app, no_patience, bad_spawn):
settings = app.tornado_application.settings
db = app.db
name = 'prim'
user = add_user(db, app=app, name=name)
@@ -529,7 +528,6 @@ def test_bad_spawn(app, no_patience, bad_spawn):
@mark.gen_test
def test_slow_bad_spawn(app, no_patience, slow_bad_spawn):
settings = app.tornado_application.settings
db = app.db
name = 'zaphod'
user = add_user(db, app=app, name=name)
@@ -545,11 +543,10 @@ def test_slow_bad_spawn(app, no_patience, slow_bad_spawn):
@mark.gen_test
def test_spawn_limit(app, no_patience, slow_spawn, request):
db = app.db
settings = app.tornado_application.settings
settings['concurrent_spawn_limit'] = 2
def _restore_limit():
settings['concurrent_spawn_limit'] = 100
request.addfinalizer(_restore_limit)
p = mock.patch.dict(app.tornado_settings,
{'concurrent_spawn_limit': 2})
p.start()
request.addfinalizer(p.stop)
# start two pending spawns
names = ['ykka', 'hjarka']
@@ -597,11 +594,10 @@ def test_spawn_limit(app, no_patience, slow_spawn, request):
@mark.gen_test
def test_active_server_limit(app, request):
db = app.db
settings = app.tornado_application.settings
settings['active_server_limit'] = 2
def _restore_limit():
settings['active_server_limit'] = 0
request.addfinalizer(_restore_limit)
p = mock.patch.dict(app.tornado_settings,
{'active_server_limit': 2})
p.start()
request.addfinalizer(p.stop)
# start two pending spawns
names = ['ykka', 'hjarka']