def test_cannot_listen(self):
"""
When the program is run with an argument and a listen address specified
with a port that we can't listen on (e.g. port 1), a CannotListenError
is expected to be logged and the program should stop.
"""
temp_dir = self.useFixture(TempDir())
yield main(reactor, raw_args=[
temp_dir.path,
'--listen', ':1', # A port we can't listen on
])
# Expect a 'certs' directory to be created
self.assertThat(os.path.isdir(temp_dir.join('certs')), Equals(True))
# Expect a default certificate to be created
self.assertThat(os.path.isfile(temp_dir.join('default.pem')),
Equals(True))
# Expect to be unable to listen
flush_logged_errors(CannotListenError)
评论列表
文章目录