Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test web server: fix test broken #38

Merged
merged 2 commits into from
May 11, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions tests/web/test_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from os import path
from socket import gaierror
import ssl

from circuits.web import Controller
from circuits import handler, Component
Expand All @@ -12,6 +13,7 @@
from .helpers import urlopen, URLError

CERTFILE = path.join(path.dirname(__file__), "cert.pem")
SSL_CONTEXT = ssl._create_unverified_context() # self signed cert


class BaseRoot(Component):
Expand Down Expand Up @@ -46,10 +48,10 @@ def test_baseserver(manager, watcher):
try:
f = urlopen(server.http.base)
except URLError as e:
if type(e[0]) is gaierror:
if isinstance(e.reason, gaierror):
f = urlopen("http://127.0.0.1:9000")
else:
raise
raise e

s = f.read()
assert s == b"Hello World!"
Expand All @@ -68,10 +70,10 @@ def test_server(manager, watcher):
try:
f = urlopen(server.http.base)
except URLError as e:
if type(e[0]) is gaierror:
if isinstance(e.reason, gaierror):
f = urlopen("http://127.0.0.1:9000")
else:
raise
raise e

s = f.read()
assert s == b"Hello World!"
Expand All @@ -90,12 +92,12 @@ def test_secure_server(manager, watcher):
Root().register(server)

try:
f = urlopen(server.http.base)
f = urlopen(server.http.base, context=SSL_CONTEXT)
except URLError as e:
if type(e[0]) is gaierror:
if isinstance(e.reason, gaierror):
f = urlopen("http://127.0.0.1:9000")
else:
raise
raise e

s = f.read()
assert s == b"Hello World!"
Expand Down Expand Up @@ -142,7 +144,7 @@ def test_multi_servers(manager, watcher):
s = f.read()
assert s == b"Hello World!"

f = urlopen(secure_server.http.base)
f = urlopen(secure_server.http.base, context=SSL_CONTEXT)
s = f.read()
assert s == b"Hello World!"

Expand Down