def setUp(self):
     if is_monkey_patched():
         raise unittest.SkipTest("Can't test libev with monkey patching")
     if LibevConnection is None:
         raise unittest.SkipTest(
             'libev does not appear to be installed correctly')
     LibevConnection.initialize_reactor()
 def setUp(self):
     if is_monkey_patched():
         raise unittest.SkipTest("Can't test libev with monkey patching")
     if LibevConnection is None:
         raise unittest.SkipTest(
             'libev does not appear to be installed properly')
     ConnectionTests.setUp(self)
示例#3
0
 def setUp(self):
     if is_monkey_patched():
         raise unittest.SkipTest("Can't test libev with monkey patching")
     if LibevConnection is None:
         raise unittest.SkipTest(
             'libev does not appear to be installed properly')
     ConnectionTests.setUp(self)
示例#4
0
def noop_if_monkey_patched(f):
    if is_monkey_patched():
        @wraps(f)
        def noop(*args, **kwargs):
            return
        return noop

    return f
示例#5
0
def noop_if_monkey_patched(f):
    if is_monkey_patched():
        @wraps(f)
        def noop(*args, **kwargs):
            return
        return noop

    return f
    def setUp(self):
        if is_monkey_patched():
            raise unittest.SkipTest("Can't test libev with monkey patching.")
        if LibevConnection is None:
            raise unittest.SkipTest('libev does not appear to be installed correctly')

        LibevConnection.initialize_reactor()
        super(LibevTimerTest, self).setUp()
示例#7
0
    def setUpClass(cls):
        if is_monkey_patched():
            return
        AsyncoreConnection.initialize_reactor()
        cls.socket_patcher = patch('socket.socket', spec=socket.socket)
        cls.mock_socket = cls.socket_patcher.start()
        cls.mock_socket().connect_ex.return_value = 0
        cls.mock_socket().getsockopt.return_value = 0
        cls.mock_socket().fileno.return_value = 100

        AsyncoreConnection.add_channel = lambda *args, **kwargs: None
    def setUpClass(cls):
        if is_monkey_patched():
            return
        AsyncoreConnection.initialize_reactor()
        cls.socket_patcher = patch('socket.socket', spec=socket.socket)
        cls.mock_socket = cls.socket_patcher.start()
        cls.mock_socket().connect_ex.return_value = 0
        cls.mock_socket().getsockopt.return_value = 0
        cls.mock_socket().fileno.return_value = 100

        AsyncoreConnection.add_channel = lambda *args, **kwargs: None
示例#9
0
    def setUpClass(cls):
        if is_monkey_patched():
            return
        AsyncoreConnection.initialize_reactor()

        socket_patcher = patch('socket.socket', spec=socket.socket)
        channel_patcher = patch(
            'cassandra.io.asyncorereactor.AsyncoreConnection.add_channel',
            new=(lambda *args, **kwargs: None))

        cls.mock_socket = socket_patcher.start()
        cls.mock_socket.connect_ex.return_value = 0
        cls.mock_socket.getsockopt.return_value = 0
        cls.mock_socket.fileno.return_value = 100

        channel_patcher.start()

        cls.patchers = (socket_patcher, channel_patcher)
    def setUp(self):
        if is_monkey_patched():
            raise unittest.SkipTest("Can't test libev with monkey patching")
        if LibevConnection is None:
            raise unittest.SkipTest('libev does not appear to be installed correctly')
        LibevConnection.initialize_reactor()

        # we patch here rather than as a decorator so that the Mixin can avoid
        # specifying patch args to test methods
        patchers = [patch(obj) for obj in
                    ('socket.socket',
                     'cassandra.io.libevwrapper.IO',
                     'cassandra.io.libevreactor.LibevLoop.maybe_start'
                     )]
        for p in patchers:
            self.addCleanup(p.stop)
        for p in patchers:
            p.start()
示例#11
0
    def setUp(self):
        if is_monkey_patched():
            raise unittest.SkipTest("Can't test libev with monkey patching")
        if LibevConnection is None:
            raise unittest.SkipTest('libev does not appear to be installed correctly')
        LibevConnection.initialize_reactor()

        # we patch here rather than as a decorator so that the Mixin can avoid
        # specifying patch args to test methods
        patchers = [patch(obj) for obj in
                    ('socket.socket',
                     'cassandra.io.libevwrapper.IO',
                     'cassandra.io.libevreactor.LibevLoop.maybe_start'
                     )]
        for p in patchers:
            self.addCleanup(p.stop)
        for p in patchers:
            p.start()
    def setUpClass(cls):
        if is_monkey_patched():
            return
        AsyncoreConnection.initialize_reactor()

        socket_patcher = patch('socket.socket', spec=socket.socket)
        channel_patcher = patch(
            'cassandra.io.asyncorereactor.AsyncoreConnection.add_channel',
            new=(lambda *args, **kwargs: None)
        )

        cls.mock_socket = socket_patcher.start()
        cls.mock_socket.connect_ex.return_value = 0
        cls.mock_socket.getsockopt.return_value = 0
        cls.mock_socket.fileno.return_value = 100

        channel_patcher.start()

        cls.patchers = (socket_patcher, channel_patcher)
 def setUpClass(cls):
     if is_monkey_patched() or not ASYNCIO_AVAILABLE:
         return
     cls.connection_class = AsyncioConnection
     AsyncioConnection.initialize_reactor()
示例#14
0
 def setUp(self):
     if is_monkey_patched():
         raise unittest.SkipTest("Can't test asyncore with monkey patching")
     ConnectionTests.setUp(self)
 def setUp(self):
     if is_monkey_patched():
         raise unittest.SkipTest("Can't test asyncore with monkey patching")
     super(TestAsyncoreTimer, self).setUp()
 def setUp(self):
     if is_monkey_patched():
         raise unittest.SkipTest("Can't test asyncore with monkey patching")
     ConnectionTests.setUp(self)
示例#17
0
    from cassandra.io.asyncioreactor import AsyncioConnection
    import asynctest
    ASYNCIO_AVAILABLE = True
except (ImportError, SyntaxError):
    AsyncioConnection = None
    ASYNCIO_AVAILABLE = False

from tests import is_monkey_patched, connection_class
from tests.unit.io.utils import TimerCallback, TimerTestMixin

from mock import patch

import unittest
import time

skip_me = (is_monkey_patched() or (not ASYNCIO_AVAILABLE)
           or (connection_class is not AsyncioConnection))


@unittest.skipIf(is_monkey_patched(),
                 'runtime is monkey patched for another reactor')
@unittest.skipIf(
    connection_class is not AsyncioConnection,
    'not running asyncio tests; current connection_class is {}'.format(
        connection_class))
@unittest.skipUnless(ASYNCIO_AVAILABLE,
                     "asyncio is not available for this runtime")
class AsyncioTimerTests(TimerTestMixin, unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        if skip_me:
 def tearDownClass(cls):
     if is_monkey_patched():
         return
     cls.socket_patcher.stop()
示例#19
0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import os, socket
from ccmlib import common

from cassandra.cluster import Cluster, NoHostAvailable
from cassandra.io.asyncorereactor import AsyncoreConnection

from tests import is_monkey_patched
from tests.integration import use_cluster, remove_cluster, PROTOCOL_VERSION

if is_monkey_patched():
    LibevConnection = -1
    AsyncoreConnection = -1
else:
    try:
        from cassandra.io.libevreactor import LibevConnection
    except ImportError:
        LibevConnection = None

try:
    import unittest2 as unittest
except ImportError:
    import unittest  # noqa


# If more modules do IPV6 testing, this can be moved down to integration.__init__.
示例#20
0
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at
#
# http://www.datastax.com/terms/datastax-dse-driver-license-terms

import os, socket
from ccmlib import common

from dse.cluster import Cluster, NoHostAvailable
from dse.io.asyncorereactor import AsyncoreConnection

from tests import is_monkey_patched
from tests.integration import use_cluster, remove_cluster, PROTOCOL_VERSION

if is_monkey_patched():
    LibevConnection = -1
    AsyncoreConnection = -1
else:
    try:
        from dse.io.libevreactor import LibevConnection
    except ImportError:
        LibevConnection = None

try:
    import unittest2 as unittest
except ImportError:
    import unittest  # noqa

# If more modules do IPV6 testing, this can be moved down to integration.__init__.
# For now, just keeping the clutter here
 def setUpClass(cls):
     if is_monkey_patched() or not ASYNCIO_AVAILABLE:
         return
     cls.connection_class = AsyncioConnection
     AsyncioConnection.initialize_reactor()
    from cassandra.io.asyncioreactor import AsyncioConnection
    import asynctest
    ASYNCIO_AVAILABLE = True
except (ImportError, SyntaxError):
    AysncioConnection = None
    ASYNCIO_AVAILABLE = False

from tests import is_monkey_patched, connection_class
from tests.unit.io.utils import TimerCallback, TimerTestMixin

from mock import patch

import unittest
import time

skip_me = (is_monkey_patched() or
           (not ASYNCIO_AVAILABLE) or
           (connection_class is not AsyncioConnection))


@unittest.skipIf(is_monkey_patched(), 'runtime is monkey patched for another reactor')
@unittest.skipIf(connection_class is not AsyncioConnection,
                 'not running asyncio tests; current connection_class is {}'.format(connection_class))
@unittest.skipUnless(ASYNCIO_AVAILABLE, "asyncio is not available for this runtime")
class AsyncioTimerTests(TimerTestMixin, unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        if skip_me:
            return
        cls.connection_class = AsyncioConnection
示例#23
0
 def tearDownClass(cls):
     if is_monkey_patched():
         return
     cls.socket_patcher.stop()
示例#24
0
 def setUp(self):
     if is_monkey_patched():
         raise unittest.SkipTest("Can't test asyncore with monkey patching")
     super(TestAsyncoreTimer, self).setUp()