Skip to content

Commit

Permalink
started to add coverage for circus.green
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekziade committed Sep 10, 2013
1 parent 7104da9 commit dff593f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
23 changes: 17 additions & 6 deletions circus/tests/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def resolve_name(name):

class TestCircus(unittest.TestCase):

arbiter_factory = get_arbiter

def setUp(self):
self.arbiters = []
self.files = []
Expand Down Expand Up @@ -99,14 +101,15 @@ def _create_circus(cls, callable, plugins=None, stats=False, **kw):
worker.update(kw)
debug = kw.get('debug', False)

fact = cls.arbiter_factory
if stats:
arbiter = get_arbiter([worker], background=True, plugins=plugins,
stats_endpoint=DEFAULT_ENDPOINT_STATS,
statsd=True,
debug=debug, statsd_close_outputs=not debug)
arbiter = fact([worker], background=True, plugins=plugins,
stats_endpoint=DEFAULT_ENDPOINT_STATS,
statsd=True,
debug=debug, statsd_close_outputs=not debug)
else:
arbiter = get_arbiter([worker], background=True, plugins=plugins,
debug=debug)
arbiter = fact([worker], background=True, plugins=plugins,
debug=debug)
arbiter.start()
return testfile, arbiter

Expand Down Expand Up @@ -175,6 +178,14 @@ def run_process(test_file):
return 1


def has_gevent():
try:
import gevent # NOQA
return True
except ImportError:
return False


class TimeoutException(Exception):
pass

Expand Down
9 changes: 1 addition & 8 deletions circus/tests/test_circusd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@
from circus.arbiter import Arbiter
from circus.util import REDIRECT_TO
from circus import util
from circus.tests.support import has_gevent


CIRCUS_INI = os.path.join(os.path.dirname(__file__), 'circus.ini')


def has_gevent():
try:
import gevent # NOQA
return True
except ImportError:
return False


class TestCircusd(TestCase):

def setUp(self):
Expand Down
10 changes: 10 additions & 0 deletions circus/tests/test_green.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from unittest2 import skipIf

from circus.tests.support import has_gevent
from circus.green import get_arbiter
from circus.tests.test_arbiter import TestTrainer


@skipIf(not has_gevent(), 'Tests for Gevent')
class TestGreen(TestTrainer):
arbiter_factory = get_arbiter

0 comments on commit dff593f

Please sign in to comment.