Skip to content

Commit 68d8d5d

Browse files
hrnciarlavagetto
authored andcommitted
Replace the usage of assertEquals unit test alias removed in Python 3.12 with assertEqual
1 parent 44d2725 commit 68d8d5d

File tree

4 files changed

+55
-55
lines changed

4 files changed

+55
-55
lines changed

src/etcd/tests/unit/test_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ def test__set_version_info(self):
137137
self.client._MGET
138138
)
139139
# Verify the properties while we are here
140-
self.assertEquals('2.2.3', self.client.version)
141-
self.assertEquals('2.3.0', self.client.cluster_version)
140+
self.assertEqual('2.2.3', self.client.version)
141+
self.assertEqual('2.3.0', self.client.cluster_version)
142142

143143
def test_version_property(self):
144144
"""Ensure the version property is set on first access."""
@@ -147,15 +147,15 @@ def test_version_property(self):
147147
self.client.api_execute.return_value.getheader.return_value = None
148148

149149
# Verify the version property is set
150-
self.assertEquals('2.2.3', self.client.version)
150+
self.assertEqual('2.2.3', self.client.version)
151151

152152
def test_cluster_version_property(self):
153153
"""Ensure the cluster version property is set on first access."""
154154
data = {"etcdserver": "2.2.3", "etcdcluster": "2.3.0"}
155155
self._mock_api(200, data)
156156
self.client.api_execute.return_value.getheader.return_value = None
157157
# Verify the cluster_version property is set
158-
self.assertEquals('2.3.0', self.client.cluster_version)
158+
self.assertEqual('2.3.0', self.client.cluster_version)
159159

160160
def test_get_headers_without_auth(self):
161161
client = etcd.Client()
@@ -191,7 +191,7 @@ def test_discover(self):
191191
etcd.Client.machines = mock.create_autospec(etcd.Client.machines, return_value=[u'https://etcd2.example.com:2379'])
192192
c = etcd.Client(srv_domain="example.com", allow_reconnect=True, protocol="https")
193193
etcd.Client.machines = self.machines
194-
self.assertEquals(c.host, u'etcd1.example.com')
195-
self.assertEquals(c.port, 2379)
196-
self.assertEquals(c._machines_cache,
194+
self.assertEqual(c.host, u'etcd1.example.com')
195+
self.assertEqual(c.port, 2379)
196+
self.assertEqual(c._machines_cache,
197197
[u'https://etcd2.example.com:2379'])

src/etcd/tests/unit/test_lock.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ def test_initialization(self):
3131
"""
3232
Verify the lock gets initialized correctly
3333
"""
34-
self.assertEquals(self.locker.name, u'test_lock')
35-
self.assertEquals(self.locker.path, u'/_locks/test_lock')
36-
self.assertEquals(self.locker.is_taken, False)
34+
self.assertEqual(self.locker.name, u'test_lock')
35+
self.assertEqual(self.locker.path, u'/_locks/test_lock')
36+
self.assertEqual(self.locker.is_taken, False)
3737

3838
def test_acquire(self):
3939
"""
@@ -52,8 +52,8 @@ def test_acquire(self):
5252
}
5353
}
5454
self._mock_api(200, d)
55-
self.assertEquals(l.acquire(), True)
56-
self.assertEquals(l._sequence, '1')
55+
self.assertEqual(l.acquire(), True)
56+
self.assertEqual(l._sequence, '1')
5757

5858
def test_is_acquired(self):
5959
"""
@@ -70,19 +70,19 @@ def test_is_acquired(self):
7070
}
7171
self._mock_api(200, d)
7272
self.locker.is_taken = True
73-
self.assertEquals(self.locker.is_acquired, True)
73+
self.assertEqual(self.locker.is_acquired, True)
7474

7575
def test_is_not_acquired(self):
7676
"""
7777
Test is_acquired failures
7878
"""
7979
self.locker._sequence = '2'
8080
self.locker.is_taken = False
81-
self.assertEquals(self.locker.is_acquired, False)
81+
self.assertEqual(self.locker.is_acquired, False)
8282
self.locker.is_taken = True
8383
self._mock_exception(etcd.EtcdKeyNotFound, self.locker.lock_key)
84-
self.assertEquals(self.locker.is_acquired, False)
85-
self.assertEquals(self.locker.is_taken, False)
84+
self.assertEqual(self.locker.is_acquired, False)
85+
self.assertEqual(self.locker.is_taken, False)
8686

8787
def test_acquired(self):
8888
"""
@@ -147,11 +147,11 @@ def test_lock_key(self):
147147
with self.assertRaises(ValueError):
148148
self.locker.lock_key
149149
self.locker._sequence = '5'
150-
self.assertEquals(u'/_locks/test_lock/5',self.locker.lock_key)
150+
self.assertEqual(u'/_locks/test_lock/5',self.locker.lock_key)
151151

152152
def test_set_sequence(self):
153153
self.locker._set_sequence('/_locks/test_lock/10')
154-
self.assertEquals('10', self.locker._sequence)
154+
self.assertEqual('10', self.locker._sequence)
155155

156156
def test_find_lock(self):
157157
d = {
@@ -171,11 +171,11 @@ def test_find_lock(self):
171171
self.locker._sequence = None
172172
self.recursive_read()
173173
self.assertTrue(self.locker._find_lock())
174-
self.assertEquals(self.locker._sequence, '34')
174+
self.assertEqual(self.locker._sequence, '34')
175175

176176
def test_get_locker(self):
177177
self.recursive_read()
178-
self.assertEquals((u'/_locks/test_lock/1', etcd.EtcdResult(node={'newKey': False, '_children': [], 'createdIndex': 33, 'modifiedIndex': 33, 'value': u'2qwwwq', 'expiration': None, 'key': u'/_locks/test_lock/1', 'ttl': None, 'action': None, 'dir': False})),
178+
self.assertEqual((u'/_locks/test_lock/1', etcd.EtcdResult(node={'newKey': False, '_children': [], 'createdIndex': 33, 'modifiedIndex': 33, 'value': u'2qwwwq', 'expiration': None, 'key': u'/_locks/test_lock/1', 'ttl': None, 'action': None, 'dir': False})),
179179
self.locker._get_locker())
180180
with self.assertRaises(etcd.EtcdLockExpired):
181181
self.locker._sequence = '35'

src/etcd/tests/unit/test_old_request.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_set(self):
4242

4343
result = client.set('/testkey', 'test', ttl=19)
4444

45-
self.assertEquals(
45+
self.assertEqual(
4646
etcd.EtcdResult(
4747
**{u'action': u'SET',
4848
'node': {
@@ -67,7 +67,7 @@ def test_test_and_set(self):
6767
'"ttl":49,"modifiedIndex":203}}')
6868
)
6969
result = client.test_and_set('/testkey', 'newvalue', 'test', ttl=19)
70-
self.assertEquals(
70+
self.assertEqual(
7171
etcd.EtcdResult(
7272
**{u'action': u'SET',
7373
u'node': {
@@ -94,7 +94,7 @@ def test_test_and_test_failure(self):
9494
'test', ttl=19)
9595
except ValueError as e:
9696
#from ipdb import set_trace; set_trace()
97-
self.assertEquals(
97+
self.assertEqual(
9898
'The given PrevValue is not equal'
9999
' to the value of the key : TestAndSet: 1!=3', str(e))
100100

@@ -111,7 +111,7 @@ def test_delete(self):
111111
'"modifiedIndex":189}}')
112112
)
113113
result = client.delete('/testkey')
114-
self.assertEquals(etcd.EtcdResult(
114+
self.assertEqual(etcd.EtcdResult(
115115
**{u'action': u'DELETE',
116116
u'node': {
117117
u'expiration': u'2013-09-14T01:06:35.5242587+02:00',
@@ -133,7 +133,7 @@ def test_get(self):
133133
)
134134

135135
result = client.get('/testkey')
136-
self.assertEquals(etcd.EtcdResult(
136+
self.assertEqual(etcd.EtcdResult(
137137
**{u'action': u'GET',
138138
u'node': {
139139
u'modifiedIndex': 190,
@@ -154,7 +154,7 @@ def test_not_in(self):
154154
client = etcd.Client()
155155
client.get = mock.Mock(side_effect=etcd.EtcdKeyNotFound())
156156
result = '/testkey' not in client
157-
self.assertEquals(True, result)
157+
self.assertEqual(True, result)
158158

159159
def test_in(self):
160160
""" Can check if key is in client """
@@ -169,7 +169,7 @@ def test_in(self):
169169
)
170170
result = '/testkey' in client
171171

172-
self.assertEquals(True, result)
172+
self.assertEqual(True, result)
173173

174174
def test_simple_watch(self):
175175
""" Can watch values """
@@ -186,7 +186,7 @@ def test_simple_watch(self):
186186
'"modifiedIndex":192}}')
187187
)
188188
result = client.watch('/testkey')
189-
self.assertEquals(
189+
self.assertEqual(
190190
etcd.EtcdResult(
191191
**{u'action': u'SET',
192192
u'node': {
@@ -213,7 +213,7 @@ def test_index_watch(self):
213213
'"modifiedIndex":180}}')
214214
)
215215
result = client.watch('/testkey', index=180)
216-
self.assertEquals(
216+
self.assertEqual(
217217
etcd.EtcdResult(
218218
**{u'action': u'SET',
219219
u'node': {
@@ -267,15 +267,15 @@ def test_get(self):
267267
response = FakeHTTPResponse(status=200, data='arbitrary json data')
268268
client.http.request = mock.Mock(return_value=response)
269269
result = client.api_execute('/v1/keys/testkey', client._MGET)
270-
self.assertEquals('arbitrary json data'.encode('utf-8'), result.data)
270+
self.assertEqual('arbitrary json data'.encode('utf-8'), result.data)
271271

272272
def test_delete(self):
273273
""" http delete request """
274274
client = etcd.Client()
275275
response = FakeHTTPResponse(status=200, data='arbitrary json data')
276276
client.http.request = mock.Mock(return_value=response)
277277
result = client.api_execute('/v1/keys/testkey', client._MDELETE)
278-
self.assertEquals('arbitrary json data'.encode('utf-8'), result.data)
278+
self.assertEqual('arbitrary json data'.encode('utf-8'), result.data)
279279

280280
def test_get_error(self):
281281
""" http get error request 101"""
@@ -289,15 +289,15 @@ def test_get_error(self):
289289
client.api_execute('/v2/keys/testkey', client._MGET)
290290
assert False
291291
except etcd.EtcdKeyNotFound as e:
292-
self.assertEquals(str(e), 'message : cause')
292+
self.assertEqual(str(e), 'message : cause')
293293

294294
def test_put(self):
295295
""" http put request """
296296
client = etcd.Client()
297297
response = FakeHTTPResponse(status=200, data='arbitrary json data')
298298
client.http.request_encode_body = mock.Mock(return_value=response)
299299
result = client.api_execute('/v2/keys/testkey', client._MPUT)
300-
self.assertEquals('arbitrary json data'.encode('utf-8'), result.data)
300+
self.assertEqual('arbitrary json data'.encode('utf-8'), result.data)
301301

302302
def test_test_and_set_error(self):
303303
""" http post error request 101 """
@@ -311,7 +311,7 @@ def test_test_and_set_error(self):
311311
client.api_execute('/v2/keys/testkey', client._MPUT, payload)
312312
self.fail()
313313
except ValueError as e:
314-
self.assertEquals('message : cause', str(e))
314+
self.assertEqual('message : cause', str(e))
315315

316316
def test_set_not_file_error(self):
317317
""" http post error request 102 """
@@ -325,7 +325,7 @@ def test_set_not_file_error(self):
325325
client.api_execute('/v2/keys/testkey', client._MPUT, payload)
326326
self.fail()
327327
except etcd.EtcdNotFile as e:
328-
self.assertEquals('message : cause', str(e))
328+
self.assertEqual('message : cause', str(e))
329329

330330
def test_get_error_unknown(self):
331331
""" http get error request unknown """

0 commit comments

Comments
 (0)