Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env python
import sys
from circuits import Component
class App(Component):
def started(self, *args):
try:
code = int(sys.argv[1])
except ValueError:
code = sys.argv[1]
raise SystemExit(code)
def main():
App().run()
if __name__ == "__main__":
main()
#!/usr/bin/env python
from __future__ import print_function
import pytest
from circuits import Component, Event
pytestmark = pytest.mark.skip("XXX: This test fails intermittently")
class test(Event):
"""test Event"""
class coroutine1(Event):
"""coroutine Event"""
complete = True
class coroutine2(Event):
"""coroutine Event"""
complete = True
class App(Component):
returned = False
#!/usr/bin/env python
from __future__ import print_function
import pytest
from circuits import Component, Event, handler
class test(Event):
"""test Event"""
success = True
class foo(Event):
"""foo Event"""
class App(Component):
@handler("test", priority=1)
def on_test(self, event):
event.stop()
yield
@handler("test")
def on_test_ignored(self):
return "Hello World!"
@pytest.fixture
@handler("test", filter=True)
def on_test(self, event, *args, **kwargs):
self.events_executed.append('test_filter')
return True
#!/usr/bin/env python
import pytest
from circuits.core import Component, Event, TimeoutError, handler
class wait(Event):
"""wait Event"""
success = True
class call(Event):
"""call Event"""
success = True
class hello(Event):
"""hello Event"""
success = True
from circuits.core import Component, Event, TimeoutError, handler
class wait(Event):
"""wait Event"""
success = True
class call(Event):
"""call Event"""
success = True
class hello(Event):
"""hello Event"""
success = True
class App(Component):
@handler('wait')
def _on_wait(self, timeout=-1):
result = self.fire(hello())
try:
yield self.wait('hello', timeout=timeout)
except TimeoutError as e:
yield e
else:
yield result
#!/usr/bin/env python
import pytest
from circuits.core import Component, Event, TimeoutError, handler
class wait(Event):
"""wait Event"""
success = True
class call(Event):
"""call Event"""
success = True
class hello(Event):
"""hello Event"""
success = True
class App(Component):
@handler('wait')
def _on_wait(self, timeout=-1):
result = self.fire(hello())
def __init__(self, *args, **kwargs):
super(Client, self).__init__(*args, **kwargs)
self._buffer = []
self.done = False
def read(self, data):
self._buffer.append(data)
if data.find(b"\r\n") != -1:
self.done = True
def buffer(self):
return b''.join(self._buffer)
class Root(Controller):
def index(self):
return "Hello World!"
def test(webapp):
transport = TCPClient()
client = Client()
client += transport
client.start()
host, port, resource, secure = parse_url(webapp.server.http.base)
client.fire(connect(host, port))
assert pytest.wait_for(transport, "connected")
client.fire(write(b"GET / HTTP/1.1\r\n"))
#!/usr/bin/env python
import pytest
from circuits.web import Controller
try:
from httplib import HTTPConnection
except ImportError:
from http.client import HTTPConnection # NOQA
class Root(Controller):
def GET(self):
return "GET"
def PUT(self):
return "PUT"
def POST(self):
return "POST"
def DELETE(self):
return "DELETE"
@pytest.mark.parametrize(("method"), ["GET", "PUT", "POST", "DELETE"])
def test(webapp, method):
#!/usr/bin/env python
from circuits.web import Controller
from circuits.web.client import Client, request
class Root(Controller):
def index(self):
return "Hello World!"
def test(webapp):
client = Client()
client.start()
client.fire(request("GET", webapp.server.http.base))
while client.response is None:
pass
client.stop()
response = client.response