mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-01 21:34:40 -05:00
Bugbear: Add Mutable Parameter fixes (#9682)
Part of #9366 Adds in fixes for B006 and B008, both relating to mutable parameter lint errors. Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>
This commit is contained in:
parent
64f4f506c5
commit
2ca4e349e9
38 changed files with 224 additions and 113 deletions
|
|
@ -13,6 +13,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import logging
|
||||
from typing import Optional
|
||||
|
||||
from mock import Mock
|
||||
|
||||
|
|
@ -180,7 +181,11 @@ class MatrixFederationAgentTests(unittest.TestCase):
|
|||
_check_logcontext(context)
|
||||
|
||||
def _handle_well_known_connection(
|
||||
self, client_factory, expected_sni, content, response_headers={}
|
||||
self,
|
||||
client_factory,
|
||||
expected_sni,
|
||||
content,
|
||||
response_headers: Optional[dict] = None,
|
||||
):
|
||||
"""Handle an outgoing HTTPs connection: wire it up to a server, check that the
|
||||
request is for a .well-known, and send the response.
|
||||
|
|
@ -202,10 +207,12 @@ class MatrixFederationAgentTests(unittest.TestCase):
|
|||
self.assertEqual(
|
||||
request.requestHeaders.getRawHeaders(b"user-agent"), [b"test-agent"]
|
||||
)
|
||||
self._send_well_known_response(request, content, headers=response_headers)
|
||||
self._send_well_known_response(request, content, headers=response_headers or {})
|
||||
return well_known_server
|
||||
|
||||
def _send_well_known_response(self, request, content, headers={}):
|
||||
def _send_well_known_response(
|
||||
self, request, content, headers: Optional[dict] = None
|
||||
):
|
||||
"""Check that an incoming request looks like a valid .well-known request, and
|
||||
send back the response.
|
||||
"""
|
||||
|
|
@ -213,7 +220,7 @@ class MatrixFederationAgentTests(unittest.TestCase):
|
|||
self.assertEqual(request.path, b"/.well-known/matrix/server")
|
||||
self.assertEqual(request.requestHeaders.getRawHeaders(b"host"), [b"testserv"])
|
||||
# send back a response
|
||||
for k, v in headers.items():
|
||||
for k, v in (headers or {}).items():
|
||||
request.setHeader(k, v)
|
||||
request.write(content)
|
||||
request.finish()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue