Skip to content

Commit

Permalink
Merge pull request #38 from treemo/master
Browse files Browse the repository at this point in the history
test web server: fix test broken
  • Loading branch information
prologic committed May 11, 2015
2 parents 142f9a9 + 0a19fe2 commit 7b037b7
Showing 1 changed file with 10 additions and 8 deletions.
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

0 comments on commit 7b037b7

Please sign in to comment.