Skip to content

Commit

Permalink
test_connection: improve tests
Browse files Browse the repository at this point in the history
Thanks to Daira for the suggestions.
  • Loading branch information
warner committed Apr 15, 2016
1 parent ef38c82 commit 26292fb
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/foolscap/test/test_connection.py
Expand Up @@ -15,8 +15,7 @@ def checkTCPEndpoint(self, hint, expected_host, expected_port):
ep, host = get_endpoint(hint, {"tcp": DefaultTCP()})
self.failUnless(isinstance(ep, endpoints.HostnameEndpoint), ep)
# note: this is fragile, and will break when Twisted changes the
# internals of TCP4ClientEndpoint. Hopefully we'll switch to
# HostnameEndpoint before then. Although that will break too.
# internals of HostnameEndpoint.
self.failUnlessEqual(ep._host, expected_host)
self.failUnlessEqual(ep._port, expected_port)

Expand All @@ -40,12 +39,18 @@ def testConvertLegacyHint(self):
"unix:fd=1") # equals signs, key=value -style

def testTCP(self):
self.checkTCPEndpoint("tcp:127.0.0.1:9900",
"127.0.0.1", 9900)
self.checkTCPEndpoint("tcp:127.0.0.1:9900", "127.0.0.1", 9900)
self.checkTCPEndpoint("tcp:hostname:9900", "hostname", 9900)
self.assertRaises(ipb.InvalidHintError,
self.checkTCPEndpoint, "tcp:hostname:NOTAPORT",
None, None)

def testLegacyTCP(self):
self.checkTCPEndpoint("127.0.0.1:9900",
"127.0.0.1", 9900)
self.checkTCPEndpoint("127.0.0.1:9900", "127.0.0.1", 9900)
self.checkTCPEndpoint("hostname:9900", "hostname", 9900)
self.assertRaises(ipb.InvalidHintError,
self.checkTCPEndpoint, "hostname:NOTAPORT",
None, None)

def testExtensionsFromFuture(self):
self.checkUnknownEndpoint("udp:127.0.0.1:7700")
Expand Down

0 comments on commit 26292fb

Please sign in to comment.