Skip to content

Commit fd03b37

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 fd03b37

File tree

5 files changed

+38
-24
lines changed

5 files changed

+38
-24
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: 34 additions & 19 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,11 @@ def test_batch_is_included(self):
4747
with BatchQuery(timestamp=timedelta(seconds=30)) as b:
4848
TestTimestampModel.batch(b).create(count=1)
4949

50+
<<<<<<< Updated upstream
5051
"USING TIMESTAMP".should.be.within(m.call_args[0][0].query_string)
52+
=======
53+
assert re.search("USING TIMESTAMP", m.call_args[0][0].query_string)
54+
>>>>>>> Stashed changes
5155

5256

5357
class CreateWithTimestampTest(BaseTimestampTest):
@@ -58,47 +62,52 @@ def test_batch(self):
5862
TestTimestampModel.timestamp(timedelta(seconds=10)).batch(b).create(count=1)
5963

6064
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")
65+
assert re.search(r"INSERT.*USING TIMESTAMP", query)
66+
assert not re.search(r"TIMESTAMP.*INSERT", query)
6467

6568
def test_timestamp_not_included_on_normal_create(self):
6669
with mock.patch.object(self.session, "execute") as m:
6770
TestTimestampModel.create(count=2)
6871

72+
<<<<<<< Updated upstream
6973
"USING TIMESTAMP".shouldnt.be.within(m.call_args[0][0].query_string)
74+
=======
75+
assert not re.search("USING TIMESTAMP", m.call_args[0][0].query_string)
76+
>>>>>>> Stashed changes
7077

7178
def test_timestamp_is_set_on_model_queryset(self):
7279
delta = timedelta(seconds=30)
7380
tmp = TestTimestampModel.timestamp(delta)
74-
tmp._timestamp.should.equal(delta)
81+
assert tmp._timestamp == delta
7582

7683
def test_non_batch_syntax_integration(self):
7784
tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).create(count=1)
78-
tmp.should.be.ok
85+
assert tmp
7986

8087
def test_non_batch_syntax_with_tll_integration(self):
8188
tmp = TestTimestampModel.timestamp(timedelta(seconds=30)).ttl(30).create(count=1)
82-
tmp.should.be.ok
89+
assert tmp
8390

8491
def test_non_batch_syntax_unit(self):
8592

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

96+
<<<<<<< Updated upstream
8997
query = m.call_args[0][0].query_string
9098

9199
"USING TIMESTAMP".should.be.within(query)
100+
=======
101+
assert re.search("USING TIMESTAMP", m.call_args[0][0].query_string)
102+
>>>>>>> Stashed changes
92103

93104
def test_non_batch_syntax_with_ttl_unit(self):
94105

95106
with mock.patch.object(self.session, "execute") as m:
96107
TestTimestampModel.timestamp(timedelta(seconds=30)).ttl(30).create(
97108
count=1)
98109

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

103112

104113
class UpdateWithTimestampTest(BaseTimestampTest):
@@ -111,16 +120,24 @@ def test_instance_update_includes_timestamp_in_query(self):
111120

112121
with mock.patch.object(self.session, "execute") as m:
113122
self.instance.timestamp(timedelta(seconds=30)).update(count=2)
123+
<<<<<<< Updated upstream
114124

115125
"USING TIMESTAMP".should.be.within(m.call_args[0][0].query_string)
126+
=======
127+
assert re.search("USING TIMESTAMP", m.call_args[0][0].query_string)
128+
>>>>>>> Stashed changes
116129

117130
def test_instance_update_in_batch(self):
118131
with mock.patch.object(self.session, "execute") as m:
119132
with BatchQuery() as b:
120133
self.instance.batch(b).timestamp(timedelta(seconds=30)).update(count=2)
121134

135+
<<<<<<< Updated upstream
122136
query = m.call_args[0][0].query_string
123137
"USING TIMESTAMP".should.be.within(query)
138+
=======
139+
assert re.search("USING TIMESTAMP", m.call_args[0][0].query_string)
140+
>>>>>>> Stashed changes
124141

125142

126143
class DeleteWithTimestampTest(BaseTimestampTest):
@@ -132,7 +149,7 @@ def test_non_batch(self):
132149
uid = uuid4()
133150
tmp = TestTimestampModel.create(id=uid, count=1)
134151

135-
TestTimestampModel.get(id=uid).should.be.ok
152+
assert TestTimestampModel.get(id=uid)
136153

137154
tmp.timestamp(timedelta(seconds=5)).delete()
138155

@@ -146,15 +163,15 @@ def test_non_batch(self):
146163

147164
# calling .timestamp sets the TS on the model
148165
tmp.timestamp(timedelta(seconds=5))
149-
tmp._timestamp.should.be.ok
166+
assert tmp._timestamp
150167

151168
# calling save clears the set timestamp
152169
tmp.save()
153-
tmp._timestamp.shouldnt.be.ok
170+
assert not tmp._timestamp
154171

155172
tmp.timestamp(timedelta(seconds=5))
156173
tmp.update()
157-
tmp._timestamp.shouldnt.be.ok
174+
assert not tmp._timestamp
158175

159176
def test_blind_delete(self):
160177
"""
@@ -163,7 +180,7 @@ def test_blind_delete(self):
163180
uid = uuid4()
164181
tmp = TestTimestampModel.create(id=uid, count=1)
165182

166-
TestTimestampModel.get(id=uid).should.be.ok
183+
assert TestTimestampModel.get(id=uid)
167184

168185
TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=5)).delete()
169186

@@ -182,7 +199,7 @@ def test_blind_delete_with_datetime(self):
182199
uid = uuid4()
183200
tmp = TestTimestampModel.create(id=uid, count=1)
184201

185-
TestTimestampModel.get(id=uid).should.be.ok
202+
assert TestTimestampModel.get(id=uid)
186203

187204
plus_five_seconds = datetime.now() + timedelta(seconds=5)
188205

@@ -200,11 +217,9 @@ def test_delete_in_the_past(self):
200217
uid = uuid4()
201218
tmp = TestTimestampModel.create(id=uid, count=1)
202219

203-
TestTimestampModel.get(id=uid).should.be.ok
220+
assert TestTimestampModel.get(id=uid)
204221

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

208225
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)