Windows doesn't properly support SO_REUSEADDR, so that's disabled in Python, and thus rebinding fails. For successful testing, reuse port instead.

This commit is contained in:
L. Kärkkäinen 2020-03-21 20:20:03 +02:00
parent 5f8fc0c850
commit 036c1d7019

View File

@ -95,7 +95,10 @@ class SanicTestClient:
if self.port:
server_kwargs = dict(
host=host or self.host, port=self.port, **server_kwargs
host=host or self.host,
port=self.port,
reuse_port=True, # Try to avoid test failures on Windows
**server_kwargs,
)
host, port = host or self.host, self.port
else: