Skip to content

Commit

Permalink
Add more handling for OS specific error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
adiroiban committed May 4, 2024
1 parent cd3f1d1 commit 4b8d0ae
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/twisted/internet/test/test_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
from twisted.internet.testing import MemoryReactor, StringTransport
from twisted.logger import Logger
from twisted.python import log
from twisted.python.compat import _PYPY
from twisted.python.failure import Failure
from twisted.python.runtime import platform
from twisted.test.test_tcp import (
Expand Down Expand Up @@ -770,13 +771,15 @@ def test(message):
self.assertConnectPortError(-1, message)

if self.addressClass == IPv4Address:
if platform.isWindows():
if _PYPY:
test(("port must be 0-65535.",))

Check warning on line 775 in src/twisted/internet/test/test_tcp.py

View check run for this annotation

Codecov / codecov/patch

src/twisted/internet/test/test_tcp.py#L775

Added line #L775 was not covered by tests
elif platform.isWindows():
if self.reactorFactory is IOCPReactor:
# Windows IOCP reactor.
test(("can't convert negative value to unsigned short",))
else:
# Windows select reactor.
test(("connect_ex(): port must be 0-65535.",))
test((-8, "Servname not supported for ai_socktype"))
else:
test(("connect_ex(): port must be 0-65535.",))
else:
Expand All @@ -787,7 +790,9 @@ def test(message):
test(("can't convert negative value to unsigned short",))
else:
# Windows select reactor.
test((-8, "Servname not supported for ai_socktype"))
test(("connect_ex(): port must be 0-65535.",))
elif platform.isMacOSX():
test((8, "nodename nor servname provided, or not known"))
else:
test((-8, "Servname not supported for ai_socktype"))

Expand All @@ -800,7 +805,11 @@ def test_connectPortOverflow(self):
def test(message):
self.assertConnectPortError(65536, message)

if platform.isWindows():
if _PYPY:
test(("port must be 0-65535.",))

Check warning on line 809 in src/twisted/internet/test/test_tcp.py

View check run for this annotation

Codecov / codecov/patch

src/twisted/internet/test/test_tcp.py#L809

Added line #L809 was not covered by tests
elif platform.isMacOSX() and self.addressClass == IPv6Address:
test((8, "nodename nor servname provided, or not known"))
elif platform.isWindows():
if self.reactorFactory is IOCPReactor:
# Windows IOCP reactor.
test(("value too large to convert to unsigned short",))
Expand Down

0 comments on commit 4b8d0ae

Please sign in to comment.