Skip to content

Commit

Permalink
Fixed UNIX Web server tests on OS X (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
prologic committed Jun 19, 2016
1 parent fd77567 commit 1ac80b5
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions tests/web/test_servers.py
@@ -1,28 +1,45 @@
#!/usr/bin/env python


import pytest
if pytest.PYVER < (2, 7):
pytest.skip("This test requires Python=>2.7")
from pytest import fixture

from os import path
from socket import gaierror
import os
import ssl
import sys
import tempfile
from os import path
from socket import gaierror

from circuits.web import Controller
from circuits import handler, Component
from circuits.web import BaseServer, Server


from .helpers import urlopen, URLError


if pytest.PYVER < (2, 7):
pytest.skip("This test requires Python=>2.7")


CERTFILE = path.join(path.dirname(__file__), "cert.pem")


# self signed cert
if pytest.PYVER >= (2, 7, 9):
SSL_CONTEXT = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
SSL_CONTEXT.verify_mode = ssl.CERT_NONE


@fixture
def tmpfile(request):
tmpdir = tempfile.mkdtemp()
filename = os.path.join(tmpdir, "test.sock")

return filename


class BaseRoot(Component):

channel = "web"
Expand Down Expand Up @@ -117,14 +134,11 @@ def test_secure_server(manager, watcher):
watcher.wait("unregistered")


def test_unixserver(manager, watcher, tmpdir):
def test_unixserver(manager, watcher, tmpfile):
if pytest.PLATFORM == "win32":
pytest.skip("Unsupported Platform")

sockpath = tmpdir.ensure("test.sock")
socket = str(sockpath)

server = Server(socket).register(manager)
server = Server(tmpfile).register(manager)
MakeQuiet().register(server)
watcher.wait("ready")

Expand Down

0 comments on commit 1ac80b5

Please sign in to comment.