Skip to content

Commit 946f0e9

Browse files
committed
tests: drop sure package
This package colides with twisted implementation, which ends up in the following error: ``` File "/home/runner/work/python-driver/python-driver/.venv/lib/python3.11/site-packages/sure/__init__.py", line 1084, in _new_dir patched = [x for x in old_dir(obj[0]) if isinstance(getattr(obj[0], x, None), AssertionBuilder)] File "/home/runner/work/python-driver/python-driver/.venv/lib/python3.11/site-packages/sure/__init__.py", line 1084, in <listcomp> patched = [x for x in old_dir(obj[0]) if isinstance(getattr(obj[0], x, None), AssertionBuilder)] File "/home/runner/work/python-driver/python-driver/.venv/lib/python3.11/site-packages/zope/interface/ro.py", line 224, in __get__ for k in dir(klass): File "/home/runner/work/python-driver/python-driver/.venv/lib/python3.11/site-packages/sure/__init__.py", line 1084, in _new_dir patched = [x for x in old_dir(obj[0]) if isinstance(getattr(obj[0], x, None), AssertionBuilder)] builtins.RecursionError: maximum recursion depth exceeded while calling a Python object ```
1 parent 5225556 commit 946f0e9

File tree

5 files changed

+23
-32
lines changed

5 files changed

+23
-32
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ dev = [
3939
"pytest",
4040
"PyYAML",
4141
"pytz",
42-
"sure",
4342
"scales",
4443
"pure-sasl",
4544
"twisted[tls]",

tests/integration/cqlengine/test_timestamp.py

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import re
1516
from datetime import timedelta, datetime
1617
from unittest import mock
17-
import sure
1818
from uuid import uuid4
1919

2020
from cassandra.cqlengine import columns
@@ -47,7 +47,7 @@ def test_batch_is_included(self):
4747
with BatchQuery(timestamp=timedelta(seconds=30)) as b:
4848
TestTimestampModel.batch(b).create(count=1)
4949

50-
"USING TIMESTAMP".should.be.within(m.call_args[0][0].query_string)
50+
assert "USING TIMESTAMP" in m.call_args[0][0].query_string
5151

5252

5353
class CreateWithTimestampTest(BaseTimestampTest):
@@ -58,47 +58,42 @@ def test_batch(self):
5858
TestTimestampModel.timestamp(timedelta(seconds=10)).batch(b).create(count=1)
5959

6060
query = m.call_args[0][0].query_string
61-
62-
query.should.match(r"INSERT.*USING TIMESTAMP")
63-
query.should_not.match(r"TIMESTAMP.*INSERT")
61+
assert re.search(r"INSERT.*USING TIMESTAMP", query)
62+
assert not re.search(r"TIMESTAMP.*INSERT", query)
6463

6564
def test_timestamp_not_included_on_normal_create(self):
6665
with mock.patch.object(self.session, "execute") as m:
6766
TestTimestampModel.create(count=2)
6867

69-
"USING TIMESTAMP".shouldnt.be.within(m.call_args[0][0].query_string)
68+
assert not re.search("USING TIMESTAMP", m.call_args[0][0].query_string)
7069

7170
def test_timestamp_is_set_on_model_queryset(self):
7271
delta = timedelta(seconds=30)
7372
tmp = TestTimestampModel.timestamp(delta)
74-
tmp._timestamp.should.equal(delta)
73+
assert tmp._timestamp == delta
7574

7675
def test_non_batch_syntax_integration(self):
7776
tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).create(count=1)
78-
tmp.should.be.ok
77+
assert tmp
7978

8079
def test_non_batch_syntax_with_tll_integration(self):
8180
tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).ttl(30).create(count=1)
82-
tmp.should.be.ok
81+
assert tmp
8382

8483
def test_non_batch_syntax_unit(self):
8584

8685
with mock.patch.object(self.session, "execute") as m:
8786
TestTimestampModel.timestamp(timedelta(seconds=30)).create(count=1)
8887

89-
query = m.call_args[0][0].query_string
90-
91-
"USING TIMESTAMP".should.be.within(query)
88+
assert "USING TIMESTAMP" in m.call_args[0][0].query_string
9289

9390
def test_non_batch_syntax_with_ttl_unit(self):
9491

9592
with mock.patch.object(self.session, "execute") as m:
9693
TestTimestampModel.timestamp(timedelta(seconds=30)).ttl(30).create(
9794
count=1)
9895

99-
query = m.call_args[0][0].query_string
100-
101-
query.should.match(r"USING TTL \d* AND TIMESTAMP")
96+
assert re.search(r"USING TTL \d* AND TIMESTAMP", m.call_args[0][0].query_string)
10297

10398

10499
class UpdateWithTimestampTest(BaseTimestampTest):
@@ -112,15 +107,14 @@ def test_instance_update_includes_timestamp_in_query(self):
112107
with mock.patch.object(self.session, "execute") as m:
113108
self.instance.timestamp(timedelta(seconds=30)).update(count=2)
114109

115-
"USING TIMESTAMP".should.be.within(m.call_args[0][0].query_string)
110+
assert "USING TIMESTAMP" in m.call_args[0][0].query_string
116111

117112
def test_instance_update_in_batch(self):
118113
with mock.patch.object(self.session, "execute") as m:
119114
with BatchQuery() as b:
120115
self.instance.batch(b).timestamp(timedelta(seconds=30)).update(count=2)
121116

122-
query = m.call_args[0][0].query_string
123-
"USING TIMESTAMP".should.be.within(query)
117+
assert "USING TIMESTAMP" in m.call_args[0][0].query_string
124118

125119

126120
class DeleteWithTimestampTest(BaseTimestampTest):
@@ -132,7 +126,7 @@ def test_non_batch(self):
132126
uid = uuid4()
133127
tmp = TestTimestampModel.create(id=uid, count=1)
134128

135-
TestTimestampModel.get(id=uid).should.be.ok
129+
assert TestTimestampModel.get(id=uid)
136130

137131
tmp.timestamp(timedelta(seconds=5)).delete()
138132

@@ -146,15 +140,15 @@ def test_non_batch(self):
146140

147141
# calling .timestamp sets the TS on the model
148142
tmp.timestamp(timedelta(seconds=5))
149-
tmp._timestamp.should.be.ok
143+
assert tmp._timestamp
150144

151145
# calling save clears the set timestamp
152146
tmp.save()
153-
tmp._timestamp.shouldnt.be.ok
147+
assert not tmp._timestamp
154148

155149
tmp.timestamp(timedelta(seconds=5))
156150
tmp.update()
157-
tmp._timestamp.shouldnt.be.ok
151+
assert not tmp._timestamp
158152

159153
def test_blind_delete(self):
160154
"""
@@ -163,7 +157,7 @@ def test_blind_delete(self):
163157
uid = uuid4()
164158
tmp = TestTimestampModel.create(id=uid, count=1)
165159

166-
TestTimestampModel.get(id=uid).should.be.ok
160+
assert TestTimestampModel.get(id=uid)
167161

168162
TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=5)).delete()
169163

@@ -182,7 +176,7 @@ def test_blind_delete_with_datetime(self):
182176
uid = uuid4()
183177
tmp = TestTimestampModel.create(id=uid, count=1)
184178

185-
TestTimestampModel.get(id=uid).should.be.ok
179+
assert TestTimestampModel.get(id=uid)
186180

187181
plus_five_seconds = datetime.now() + timedelta(seconds=5)
188182

@@ -200,11 +194,9 @@ def test_delete_in_the_past(self):
200194
uid = uuid4()
201195
tmp = TestTimestampModel.create(id=uid, count=1)
202196

203-
TestTimestampModel.get(id=uid).should.be.ok
197+
assert TestTimestampModel.get(id=uid)
204198

205199
# delete the in past, should not affect the object created above
206200
TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=-60)).delete()
207201

208202
TestTimestampModel.get(id=uid)
209-
210-

tests/integration/standard/test_use_keyspace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
except ImportError:
88
import unittest # noqa
99

10-
from mock import patch
10+
from unittest.mock import patch
1111

1212
from cassandra.connection import Connection
1313
from cassandra.cluster import Cluster

tests/unit/io/test_eventletreactor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515

1616
import unittest
17-
from mock import patch
17+
18+
from unittest.mock import patch
1819

1920
from tests.unit.io.utils import TimerTestMixin
2021
from tests import notpypy, EVENT_LOOP_MANAGER
2122

22-
from unittest.mock import patch
2323

2424
try:
2525
from eventlet import monkey_patch

tests/unit/test_shard_aware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import unittest # noqa
1919

2020
import logging
21-
from mock import MagicMock
21+
from unittest.mock import MagicMock
2222
from concurrent.futures import ThreadPoolExecutor
2323

2424
from cassandra.cluster import ShardAwareOptions

0 commit comments

Comments
 (0)