mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Add a __repr__ to config to include its value (#2076)
It's sometimes helpful to be able to trivially dump all the config values for debugging purposes. This commit defines a repr for that.
This commit is contained in:
parent
1aa9cf0529
commit
291483dd39
@ -308,6 +308,15 @@ class Setting(object):
|
|||||||
self.order < other.order)
|
self.order < other.order)
|
||||||
__cmp__ = __lt__
|
__cmp__ = __lt__
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return "<%s.%s object at %x with value %r>" % (
|
||||||
|
self.__class__.__module__,
|
||||||
|
self.__class__.__name__,
|
||||||
|
id(self),
|
||||||
|
self.value,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
Setting = SettingMeta('Setting', (Setting,), {})
|
Setting = SettingMeta('Setting', (Setting,), {})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -435,3 +435,10 @@ def test_bind_fd():
|
|||||||
with AltArgs(["prog_name", "-b", "fd://42"]):
|
with AltArgs(["prog_name", "-b", "fd://42"]):
|
||||||
app = NoConfigApp()
|
app = NoConfigApp()
|
||||||
assert app.cfg.bind == ["fd://42"]
|
assert app.cfg.bind == ["fd://42"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_repr():
|
||||||
|
c = config.Config()
|
||||||
|
c.set("workers", 5)
|
||||||
|
|
||||||
|
assert "with value 5" in repr(c.settings['workers'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user