Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions cassandra/cqlengine/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,8 @@

from cassandra.cqlengine import UnicodeMixin, ValidationError

import sys

if sys.version_info >= (2, 7):
def get_total_seconds(td):
return td.total_seconds()
else:
def get_total_seconds(td):
# integer division used here to emulate built-in total_seconds
return ((86400 * td.days + td.seconds) * 10 ** 6 + td.microseconds) / 10 ** 6

def get_total_seconds(td):
return td.total_seconds()

class QueryValue(UnicodeMixin):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def run_setup(extensions):
include_package_data=True,
install_requires=dependencies,
extras_require=_EXTRAS_REQUIRE,
tests_require=['nose', 'mock>=2.0.0', 'PyYAML', 'pytz', 'sure'],
tests_require=['nose', 'PyYAML', 'pytz', 'sure'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
Expand Down
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
-r requirements.txt
scales
pynose
mock>1.1
ccm>=2.1.2
pytz
sure
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cloud/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from cassandra.auth import PlainTextAuthProvider
from cassandra.policies import TokenAwarePolicy, DCAwareRoundRobinPolicy, ConstantReconnectionPolicy

from mock import patch
from unittest.mock import patch

from tests.integration import requirescloudproxy
from tests.util import wait_until_not_raised
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import copy
from mock import patch
from unittest.mock import patch

from cassandra.cqlengine import columns
from cassandra.cqlengine.management import drop_table, sync_table, _get_table_metadata, _update_options
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/management/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
import unittest

import mock
from unittest import mock
import logging
from packaging.version import Version
from cassandra.cqlengine.connection import get_session, get_cluster
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/model/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
import unittest

from mock import patch
from unittest.mock import patch

from cassandra.cqlengine import columns, CQLEngineException
from cassandra.cqlengine.management import sync_table, drop_table, create_keyspace_simple, drop_keyspace
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/model/test_polymorphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import uuid
import mock
from unittest import mock

from cassandra.cqlengine import columns
from cassandra.cqlengine import models
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/model/test_udts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from datetime import datetime, date, time
from decimal import Decimal
from mock import Mock
from unittest.mock import Mock
from uuid import UUID, uuid4

from cassandra.cqlengine.models import Model
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/model/test_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from unittest.mock import patch
from uuid import uuid4

from mock import patch
from cassandra.cqlengine import ValidationError

from tests.integration import greaterthancass21
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/query/test_batch_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import mock
from unittest import mock

from cassandra.cqlengine import columns
from cassandra.cqlengine.connection import NOT_SET
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/query/test_queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from cassandra import InvalidRequest
from tests.integration.cqlengine.base import BaseCassEngTestCase
from cassandra.cqlengine.connection import NOT_SET
import mock
from unittest import mock
from cassandra.cqlengine import functions
from cassandra.cqlengine.management import sync_table, drop_table
from cassandra.cqlengine.models import Model
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/test_batch_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from cassandra.cqlengine.query import BatchQuery
from tests.integration.cqlengine.base import BaseCassEngTestCase

from mock import patch
from unittest.mock import patch

class TestMultiKeyModel(Model):
partition = columns.Integer(primary_key=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/test_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import mock
from unittest import mock
from uuid import uuid4

from cassandra import ConsistencyLevel as CL, ConsistencyLevel
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/cqlengine/test_ifexists.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest

import mock
from unittest import mock
from uuid import uuid4

from cassandra.cqlengine import columns
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/cqlengine/test_ifnotexists.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest

import mock
from unittest import mock
from uuid import uuid4

from cassandra.cqlengine import columns
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/cqlengine/test_lwt_conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest

import mock
from unittest import mock
from uuid import uuid4

from cassandra.cqlengine import columns
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

from datetime import timedelta, datetime
import mock
from unittest import mock
import sure
from uuid import uuid4

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/cqlengine/test_ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from cassandra.cqlengine.models import Model
from uuid import uuid4
from cassandra.cqlengine import columns
import mock
from unittest import mock
from cassandra.cqlengine.connection import get_session
from tests.integration import CASSANDRA_VERSION, greaterthancass20

Expand Down
3 changes: 1 addition & 2 deletions tests/integration/long/test_failure_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import traceback
import time
from packaging.version import Version

from mock import Mock
from unittest.mock import Mock

from cassandra.policies import HostFilterPolicy, RoundRobinPolicy
from cassandra import (
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/simulacron/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

import logging
import time

from mock import Mock, patch
from unittest.mock import Mock, patch

from cassandra import OperationTimedOut
from cassandra.cluster import (EXEC_PROFILE_DEFAULT, Cluster, ExecutionProfile,
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/standard/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from collections import deque
from copy import copy
from mock import Mock, call, patch, ANY
from unittest.mock import Mock, call, patch, ANY
import time
from uuid import uuid4
import logging
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/standard/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import unittest

from functools import partial
from mock import patch
from unittest.mock import patch
import logging
import sys
import threading
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/standard/test_custom_protocol_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from tests.integration.standard.utils import create_table_with_all_types, get_all_primitive_params

import uuid
import mock
from unittest import mock


def setup_module():
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/standard/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import time
import os
from packaging.version import Version
from mock import Mock, patch
from unittest.mock import Mock, patch

from cassandra import AlreadyExists, SignatureDescriptor, UserFunctionDescriptor, UserAggregateDescriptor

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/standard/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import random
import re

import mock
from unittest import mock


log = logging.getLogger(__name__)
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/advanced/cloud/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
import tempfile
import os
import shutil

import unittest
from unittest.mock import patch

from cassandra import DriverException
from cassandra.datastax import cloud

from mock import patch

from tests import notwindows

class CloudTests(unittest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/advanced/test_insights.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import unittest

import logging
from mock import sentinel
import sys
from unittest.mock import sentinel

from cassandra import ConsistencyLevel
from cassandra.cluster import (
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/advanced/test_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest

from mock import Mock
from unittest.mock import Mock

from cassandra.pool import Host
from cassandra.policies import RoundRobinPolicy
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/cqlengine/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
# limitations under the License.

import unittest
from unittest.mock import Mock

from cassandra.cluster import _ConfigMode
from cassandra.cqlengine import connection
from cassandra.query import dict_factory

from mock import Mock


class ConnectionTest(unittest.TestCase):

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/io/test_asyncioreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tests import is_monkey_patched, connection_class
from tests.unit.io.utils import TimerCallback, TimerTestMixin

from mock import patch
from unittest.mock import patch

import unittest
import time
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/io/test_asyncorereactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
import unittest

from mock import patch
from unittest.mock import patch
import socket
import cassandra.io.asyncorereactor as asyncorereactor
from cassandra.io.asyncorereactor import AsyncoreConnection
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/io/test_eventletreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from tests import notpypy, EVENT_LOOP_MANAGER

from eventlet import monkey_patch
from mock import patch
from unittest.mock import patch

try:
from cassandra.io.eventletreactor import EventletConnection
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/io/test_geventreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import unittest
from unittest.mock import patch


from tests.unit.io.utils import TimerTestMixin
Expand All @@ -23,8 +24,6 @@
except ImportError:
GeventConnection = None # noqa

from mock import patch


skip_condition = GeventConnection is None or EVENT_LOOP_MANAGER != "gevent"
@unittest.skipIf(skip_condition, "Skipping the gevent tests because it's not installed")
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/io/test_libevreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
import unittest

from mock import patch, Mock
from unittest.mock import patch, Mock
import weakref
import socket

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/io/test_twistedreactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import unittest
from mock import Mock, patch
from unittest.mock import Mock, patch

from cassandra.connection import DefaultEndPoint

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/io/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from functools import wraps
from itertools import cycle
from io import BytesIO
from mock import Mock
from unittest.mock import Mock

import errno
import logging
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import logging
import socket

from mock import patch, Mock
from unittest.mock import patch, Mock

from cassandra import ConsistencyLevel, DriverException, Timeout, Unavailable, RequestExecutionException, ReadTimeout, WriteTimeout, CoordinationFailure, ReadFailure, WriteFailure, FunctionFailure, AlreadyExists,\
InvalidRequest, Unauthorized, AuthenticationFailed, OperationTimedOut, UnsupportedOperation, RequestValidationException, ConfigurationException, ProtocolVersion
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_concurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import unittest

from itertools import cycle
from mock import Mock
from unittest.mock import Mock
import time
import threading
from queue import PriorityQueue
Expand Down
Loading