Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'master' into Issue#133
  • Loading branch information
prologic committed May 31, 2017
2 parents d6d8381 + 3aecf1d commit 39cd669
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
4 changes: 3 additions & 1 deletion circuits/web/errors.py
Expand Up @@ -162,7 +162,7 @@ def __init__(self, request, response, urls, code=None):

super(redirect, self).__init__(request, response, code)

if code in (300, 301, 302, 303, 307):
if code in (300, 301, 302, 303, 307, 308):
response.headers["Content-Type"] = "text/html"
# "The ... URI SHOULD be given by the Location field
# in the response."
Expand All @@ -180,6 +180,8 @@ def __init__(self, request, response, urls, code=None):
"<a href='%s'>%s</a>."),
307: ("This resource has moved temporarily to "
"<a href='%s'>%s</a>."),
308: ("This resource has permanently moved to "
"<a href='%s'>%s</a>."),
}[code]
response.body = "<br />\n".join([msg % (u, u) for u in urls])
# Previous code may have set C-L, so we have to reset it
Expand Down
4 changes: 2 additions & 2 deletions docs/source/web/howtos.rst
Expand Up @@ -128,7 +128,7 @@ trivial example:
from circuits.net.events import write
from circuits import Component, Debugger
from circuits.web.dispatchers import WebSockets
from circuits.web.dispatchers import WebSocketsDispatcher
from circuits.web import Controller, Logger, Server, Static
Expand All @@ -152,7 +152,7 @@ trivial example:
Echo().register(app)
Root().register(app)
Logger().register(app)
WebSockets("/websocket").register(app)
WebSocketsDispatcher("/websocket").register(app)
app.run()
See the `circuits.web examples <https://github.com/circuits/circuits/tree/master/examples/web>`_.
Expand Down
1 change: 1 addition & 0 deletions requirements-test.txt
@@ -1,6 +1,7 @@
codecov
pytest
pytest-cov
pytest-timeout
flake8
isort
tox
Expand Down
24 changes: 13 additions & 11 deletions tests/core/test_call_wait.py
Expand Up @@ -5,67 +5,56 @@


class wait(Event):

"""wait Event"""
success = True


class call(Event):

"""call Event"""
success = True


class long_call(Event):

"""long_call Event"""
success = True


class long_wait(Event):

"""long_wait Event"""
success = True


class wait_return(Event):

"""wait_return Event"""
success = True


class hello(Event):

"""hello Event"""
success = True


class foo(Event):

"""foo Event"""
success = True


class get_x(Event):

"""get_x Event"""
success = True


class get_y(Event):

"""get_y Event"""
success = True


class eval(Event):

"""eval Event"""
success = True


class App(Component):

@handler("wait")
def _on_wait(self):
x = self.fire(hello())
Expand Down Expand Up @@ -168,3 +157,16 @@ def test_eval(manager, watcher, app):

value = x.value
assert value == 3


@pytest.mark.xfail(reason='Issue #226')
@pytest.mark.timeout(1)
def test_wait_too_late(manager, watcher, app):
event = foo()
manager.fire(event)
assert watcher.wait("foo_success")
manager.tick()

x = manager.wait(event, timeout=.1)
value = next(x)
assert value == list(range(1, 10))
1 change: 1 addition & 0 deletions tox.ini
Expand Up @@ -10,6 +10,7 @@ commands=py.test {posargs}
deps=
pytest
pytest-cov
pytest-timeout

[testenv:docs]
basepython=python
Expand Down

0 comments on commit 39cd669

Please sign in to comment.