mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Add test for worker_exit()
This commit is contained in:
parent
ca64a57c77
commit
b3c4260706
@ -16,7 +16,7 @@ import gunicorn.arbiter
|
|||||||
|
|
||||||
class DummyApplication(gunicorn.app.base.BaseApplication):
|
class DummyApplication(gunicorn.app.base.BaseApplication):
|
||||||
"""
|
"""
|
||||||
Dummy application that has an default configuration.
|
Dummy application that has a default configuration.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def init(self, parser, opts, args):
|
def init(self, parser, opts, args):
|
||||||
@ -39,6 +39,22 @@ def test_arbiter_shutdown_closes_listeners():
|
|||||||
listener2.close.assert_called_with()
|
listener2.close.assert_called_with()
|
||||||
|
|
||||||
|
|
||||||
|
@mock.patch('os.fork')
|
||||||
|
def test_arbiter_calls_worker_exit(mock_os_fork):
|
||||||
|
mock_os_fork.return_value = 0
|
||||||
|
|
||||||
|
arbiter = gunicorn.arbiter.Arbiter(DummyApplication())
|
||||||
|
arbiter.cfg.settings['worker_exit'] = mock.Mock()
|
||||||
|
arbiter.pid = None
|
||||||
|
mock_worker = mock.Mock()
|
||||||
|
arbiter.worker_class = mock.Mock(return_value=mock_worker)
|
||||||
|
try:
|
||||||
|
arbiter.spawn_worker()
|
||||||
|
except SystemExit:
|
||||||
|
pass
|
||||||
|
arbiter.cfg.worker_exit.assert_called_with(arbiter, mock_worker)
|
||||||
|
|
||||||
|
|
||||||
class PreloadedAppWithEnvSettings(DummyApplication):
|
class PreloadedAppWithEnvSettings(DummyApplication):
|
||||||
"""
|
"""
|
||||||
Simple application that makes use of the 'preload' feature to
|
Simple application that makes use of the 'preload' feature to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user