Skip to content

Commit 95b773c

Browse files
authored
refactor: remove webtest for flask test_client (#1769)
* refactor: remove webtest for flask test_client The refactor removes webtest as a package dependency and leaves all existing functionality intact. * fix: error when viewing a plugin that is disabled * feat: allow webserver plugin config to be partial * docs: update CHANGES
1 parent a17098d commit 95b773c

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
v9.9.9 (unreleased)
22
-------------------
33
- chore: add releases script (#1767)
4+
- refactor: remove webtest dependency (#1769)
45

56

67
v6.2.1 (2026-06-06)

errbot/core_plugins/templates/plugin_info.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ log destination: {{ plugin.log.name }}
1919

2020
log level: {{ logging.getLevelName(plugin.log.level) }}
2121

22-
{% if plugin.keys %}
22+
{% if plugin.is_activated %}
23+
{% if plugin.keys() %}
2324
**storage content**
2425

2526
Key | Value
2627
-------------------- | -----------------------
2728
{% for key, value in plugin.items() %}{{ key.ljust(20) }} | `{{ value }}`
2829
{% endfor %}
2930
{% endif %}
31+
{% endif %}
3032

3133
{% if plugin.config %}
3234
**config content**

errbot/core_plugins/webserver.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from urllib.request import unquote
88

99
from OpenSSL import crypto
10-
from webtest import TestApp
1110
from werkzeug.serving import ThreadedWSGIServer
1211

1312
from errbot import BotPlugin, botcmd, webhook
@@ -57,7 +56,6 @@ def __init__(self, *args, **kwargs):
5756
self.server = None
5857
self.server_thread = None
5958
self.ssl_context = None
60-
self.test_app = TestApp(flask_app)
6159
super().__init__(*args, **kwargs)
6260

6361
def get_configuration_template(self):
@@ -75,14 +73,14 @@ def get_configuration_template(self):
7573

7674
def check_configuration(self, configuration):
7775
# it is a pain, just assume a default config if SSL is absent or set to None
76+
ssl_template = self.get_configuration_template()["SSL"]
7877
if configuration.get("SSL", None) is None:
79-
configuration["SSL"] = {
80-
"enabled": False,
81-
"host": "0.0.0.0",
82-
"port": 3142,
83-
"certificate": "",
84-
"key": "",
85-
}
78+
configuration["SSL"] = ssl_template
79+
else:
80+
# fill in missing keys from template if they are absent
81+
for k, v in ssl_template.items():
82+
if k not in configuration["SSL"]:
83+
configuration["SSL"][k] = v
8684
super().check_configuration(configuration)
8785

8886
def activate(self):
@@ -180,7 +178,9 @@ def webhook_test(self, _, args):
180178

181179
self.log.debug("Detected your post as : %s.", contenttype)
182180

183-
response = self.test_app.post(url, params=content, content_type=contenttype)
181+
with flask_app.test_client() as client:
182+
response = client.post(url, data=content, content_type=contenttype)
183+
184184
return {
185185
"url": url,
186186
"content": content,

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
VERSION_FILE = os.path.join("errbot", "version.py")
2828

2929
deps = [
30-
"webtest==3.0.7",
3130
"setuptools>=78.1.1",
3231
"flask==3.1.3",
3332
"requests==2.32.5",
@@ -40,7 +39,6 @@
4039
"pygments-markdown-lexer==0.1.0.dev39", # syntax coloring to debug md
4140
"dulwich==1.2.1", # python implementation of git
4241
"deepmerge==2.0",
43-
"legacy-cgi==2.6.4; python_version >= '3.13'", # stopgap fix for webtest after cgi dropped from stdlib in 3.13
4442
]
4543

4644
src_root = os.curdir
@@ -90,7 +88,7 @@ def read(fname, encoding="ascii"):
9088
]
9189
},
9290
install_requires=deps,
93-
tests_require=["nose", "webtest", "requests"],
91+
tests_require=["nose", "requests"],
9492
package_data={
9593
"errbot": [
9694
"backends/*.plug",

0 commit comments

Comments
 (0)