diff --git a/pyproject.toml b/pyproject.toml index 6f4e4a8f6e..9a3cd40b5a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,6 @@ dev = [ "pytest", "PyYAML", "pytz", - "sure", "scales", "pure-sasl", "twisted[tls]", diff --git a/tests/integration/cqlengine/test_timestamp.py b/tests/integration/cqlengine/test_timestamp.py index 1b0e3d6b9d..7b10ad578f 100644 --- a/tests/integration/cqlengine/test_timestamp.py +++ b/tests/integration/cqlengine/test_timestamp.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import re from datetime import timedelta, datetime from unittest import mock -import sure from uuid import uuid4 from cassandra.cqlengine import columns @@ -47,7 +47,7 @@ def test_batch_is_included(self): with BatchQuery(timestamp=timedelta(seconds=30)) as b: TestTimestampModel.batch(b).create(count=1) - "USING TIMESTAMP".should.be.within(m.call_args[0][0].query_string) + assert "USING TIMESTAMP" in m.call_args[0][0].query_string class CreateWithTimestampTest(BaseTimestampTest): @@ -58,37 +58,34 @@ def test_batch(self): TestTimestampModel.timestamp(timedelta(seconds=10)).batch(b).create(count=1) query = m.call_args[0][0].query_string - - query.should.match(r"INSERT.*USING TIMESTAMP") - query.should_not.match(r"TIMESTAMP.*INSERT") + assert re.search(r"INSERT.*USING TIMESTAMP", query) + assert not re.search(r"TIMESTAMP.*INSERT", query) def test_timestamp_not_included_on_normal_create(self): with mock.patch.object(self.session, "execute") as m: TestTimestampModel.create(count=2) - "USING TIMESTAMP".shouldnt.be.within(m.call_args[0][0].query_string) + assert "USING TIMESTAMP" not in m.call_args[0][0].query_string def test_timestamp_is_set_on_model_queryset(self): delta = timedelta(seconds=30) tmp = TestTimestampModel.timestamp(delta) - tmp._timestamp.should.equal(delta) + assert tmp._timestamp == delta def test_non_batch_syntax_integration(self): tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).create(count=1) - tmp.should.be.ok + assert tmp def test_non_batch_syntax_with_tll_integration(self): tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).ttl(30).create(count=1) - tmp.should.be.ok + assert tmp def test_non_batch_syntax_unit(self): with mock.patch.object(self.session, "execute") as m: TestTimestampModel.timestamp(timedelta(seconds=30)).create(count=1) - query = m.call_args[0][0].query_string - - "USING TIMESTAMP".should.be.within(query) + assert "USING TIMESTAMP" in m.call_args[0][0].query_string def test_non_batch_syntax_with_ttl_unit(self): @@ -96,9 +93,7 @@ def test_non_batch_syntax_with_ttl_unit(self): TestTimestampModel.timestamp(timedelta(seconds=30)).ttl(30).create( count=1) - query = m.call_args[0][0].query_string - - query.should.match(r"USING TTL \d* AND TIMESTAMP") + assert re.search(r"USING TTL \d* AND TIMESTAMP", m.call_args[0][0].query_string) class UpdateWithTimestampTest(BaseTimestampTest): @@ -112,15 +107,14 @@ def test_instance_update_includes_timestamp_in_query(self): with mock.patch.object(self.session, "execute") as m: self.instance.timestamp(timedelta(seconds=30)).update(count=2) - "USING TIMESTAMP".should.be.within(m.call_args[0][0].query_string) + assert "USING TIMESTAMP" in m.call_args[0][0].query_string def test_instance_update_in_batch(self): with mock.patch.object(self.session, "execute") as m: with BatchQuery() as b: self.instance.batch(b).timestamp(timedelta(seconds=30)).update(count=2) - query = m.call_args[0][0].query_string - "USING TIMESTAMP".should.be.within(query) + assert "USING TIMESTAMP" in m.call_args[0][0].query_string class DeleteWithTimestampTest(BaseTimestampTest): @@ -132,7 +126,7 @@ def test_non_batch(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - TestTimestampModel.get(id=uid).should.be.ok + assert TestTimestampModel.get(id=uid) tmp.timestamp(timedelta(seconds=5)).delete() @@ -146,15 +140,15 @@ def test_non_batch(self): # calling .timestamp sets the TS on the model tmp.timestamp(timedelta(seconds=5)) - tmp._timestamp.should.be.ok + assert tmp._timestamp # calling save clears the set timestamp tmp.save() - tmp._timestamp.shouldnt.be.ok + assert not tmp._timestamp tmp.timestamp(timedelta(seconds=5)) tmp.update() - tmp._timestamp.shouldnt.be.ok + assert not tmp._timestamp def test_blind_delete(self): """ @@ -163,7 +157,7 @@ def test_blind_delete(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - TestTimestampModel.get(id=uid).should.be.ok + assert TestTimestampModel.get(id=uid) TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=5)).delete() @@ -182,7 +176,7 @@ def test_blind_delete_with_datetime(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - TestTimestampModel.get(id=uid).should.be.ok + assert TestTimestampModel.get(id=uid) plus_five_seconds = datetime.now() + timedelta(seconds=5) @@ -200,11 +194,9 @@ def test_delete_in_the_past(self): uid = uuid4() tmp = TestTimestampModel.create(id=uid, count=1) - TestTimestampModel.get(id=uid).should.be.ok + assert TestTimestampModel.get(id=uid) # delete the in past, should not affect the object created above TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=-60)).delete() TestTimestampModel.get(id=uid) - - diff --git a/tests/integration/standard/test_use_keyspace.py b/tests/integration/standard/test_use_keyspace.py index 42cf03a553..72ddbf9ef4 100644 --- a/tests/integration/standard/test_use_keyspace.py +++ b/tests/integration/standard/test_use_keyspace.py @@ -7,7 +7,7 @@ except ImportError: import unittest # noqa -from mock import patch +from unittest.mock import patch from cassandra.connection import Connection from cassandra.cluster import Cluster diff --git a/tests/unit/io/test_eventletreactor.py b/tests/unit/io/test_eventletreactor.py index e49f2459c1..d3962196a4 100644 --- a/tests/unit/io/test_eventletreactor.py +++ b/tests/unit/io/test_eventletreactor.py @@ -14,12 +14,12 @@ import unittest -from mock import patch + +from unittest.mock import patch from tests.unit.io.utils import TimerTestMixin from tests import notpypy, EVENT_LOOP_MANAGER -from unittest.mock import patch try: from eventlet import monkey_patch diff --git a/tests/unit/test_shard_aware.py b/tests/unit/test_shard_aware.py index 8b34eb2578..0d13a243ab 100644 --- a/tests/unit/test_shard_aware.py +++ b/tests/unit/test_shard_aware.py @@ -18,7 +18,7 @@ import unittest # noqa import logging -from mock import MagicMock +from unittest.mock import MagicMock from concurrent.futures import ThreadPoolExecutor from cassandra.cluster import ShardAwareOptions