From 08364f03658070114fa5182d31ea048a9c537dc4 Mon Sep 17 00:00:00 2001 From: Odysseas Fatouros Date: Tue, 2 Jan 2024 14:21:26 +0100 Subject: [PATCH] Issue #3079, add unit test --- tests/test_config.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_config.py b/tests/test_config.py index c094f6a2..f0ab392c 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -13,6 +13,7 @@ from gunicorn import config from gunicorn.app.base import Application from gunicorn.app.wsgiapp import WSGIApplication from gunicorn.errors import ConfigError +from gunicorn.util import load_class from gunicorn.workers.sync import SyncWorker from gunicorn import glogging from gunicorn.instrument import statsd @@ -55,6 +56,10 @@ class NoConfigApp(Application): pass +class CustomWorker(SyncWorker): + pass + + class WSGIApp(WSGIApplication): def __init__(self): super().__init__("no_usage", prog="gunicorn_test") @@ -63,6 +68,18 @@ class WSGIApp(WSGIApplication): pass +def test_worker_class(): + + c = config.Config() + c.set("worker_class", CustomWorker) + assert c.worker_class == CustomWorker + + try: + assert isinstance(load_class(c.worker_class), object) + except AttributeError: + pytest.fail("'load_class doesn't support type class argument'") + + def test_defaults(): c = config.Config() for s in config.KNOWN_SETTINGS: