<commit_before>from nose.plugins.skip import SkipTest

import sys
# XXX: zeropc does not work under Python < 2.6 or pypy
if (sys.version_info < (2, 6, 0) or '__pypy__' in sys.builtin_module_names):
    raise SkipTest

import gevent
import os
import random
import shutil
import tempfile
import unittest2
try:
    import zerorpc
except ImportError:
    zerorpc = None

from raven.base import Client
from raven.contrib.zerorpc import SentryMiddleware


class TempStoreClient(Client):
    def __init__(self, servers=None, **kwargs):
        self.events = []
        super(TempStoreClient, self).__init__(servers=servers, **kwargs)

    def is_enabled(self):
        return True

    def send(self, **kwargs):
        self.events.append(kwargs)


class ZeroRPCTest(unittest2.TestCase):
    def setUp(self):
        if zerorpc is None:
            raise SkipTest('zerorpc module is not available')
        self._socket_dir = tempfile.mkdtemp(prefix='ravenzerorpcunittest')
        self._server_endpoint = 'ipc://{0}'.format(os.path.join(
                    self._socket_dir, 'random_zeroserver'
        ))
<commit_msg>Use @requires to skip zerorpc tests<commit_after>from nose.plugins.skip import SkipTest

import sys
# XXX: zeropc does not work under Python < 2.6 or pypy
if (sys.version_info < (2, 6, 0) or '__pypy__' in sys.builtin_module_names):
    raise SkipTest('zerorpc does not work on pypy or python < 2.6')

import gevent
import os
import random
import shutil
import tempfile
import unittest2
try:
    import zerorpc
except ImportError:
    zerorpc = None

from raven.base import Client
from raven.contrib.zerorpc import SentryMiddleware
from raven.utils.tests import requires


class TempStoreClient(Client):
    def __init__(self, servers=None, **kwargs):
        self.events = []
        super(TempStoreClient, self).__init__(servers=servers, **kwargs)

    def is_enabled(self):
        return True

    def send(self, **kwargs):
        self.events.append(kwargs)


class ZeroRPCTest(unittest2.TestCase):
    @requires(lambda: zerorpc is not None, 'zerorpc module is not available')
    def setUp(self):
        self._socket_dir = tempfile.mkdtemp(prefix='ravenzerorpcunittest')
        self._server_endpoint = 'ipc://{0}'.format(os.path.join(
                    self._socket_dir, 'random_zeroserver'
        ))

{'fraction_non_alphanumeric': 0.0950946643717728, 'fraction_numerical': 0.00774526678141136, 'mean_word_length': 3.488416988416988, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3373241', 'n_tokens_mistral': 753, 'n_tokens_neox': 739, 'n_words': 201}