Skip to content

Commit 478e79a

Browse files
committed
fix several deprecation warnings
adding -Werror flag to pytest configuration so we can flush all of those with the test we have so we won't have user of the driver running into those and get them fixed address as soon as we support new python versions
1 parent 70e0bc2 commit 478e79a

30 files changed

+117
-58
lines changed

cassandra/cqlengine/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def setup(
323323
:param int consistency: The global default :class:`~.ConsistencyLevel` - default is the same as :attr:`.Session.default_consistency_level`
324324
:param bool lazy_connect: True if should not connect until first use
325325
:param bool retry_connect: True if we should retry to connect even if there was a connection failure initially
326-
:param \*\*kwargs: Pass-through keyword arguments for :class:`cassandra.cluster.Cluster`
326+
:param kwargs: Pass-through keyword arguments for :class:`cassandra.cluster.Cluster`
327327
"""
328328

329329
from cassandra.cqlengine import models

cassandra/cqlengine/query.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ def add_callback(self, fn, *args, **kwargs):
205205
206206
:param fn: Callable object
207207
:type fn: callable
208-
:param \*args: Positional arguments to be passed to the callback at the time of execution
209-
:param \*\*kwargs: Named arguments to be passed to the callback at the time of execution
208+
:param args: Positional arguments to be passed to the callback at the time of execution
209+
:param kwargs: Named arguments to be passed to the callback at the time of execution
210210
"""
211211
if not callable(fn):
212212
raise ValueError("Value for argument 'fn' is {0} and is not a callable object.".format(type(fn)))
@@ -276,8 +276,8 @@ class ContextQuery(object):
276276
A Context manager to allow a Model to switch context easily. Presently, the context only
277277
specifies a keyspace for model IO.
278278
279-
:param \*args: One or more models. A model should be a class type, not an instance.
280-
:param \*\*kwargs: (optional) Context parameters: can be *keyspace* or *connection*
279+
:param args: One or more models. A model should be a class type, not an instance.
280+
:param kwargs: (optional) Context parameters: can be *keyspace* or *connection*
281281
282282
For example:
283283

cassandra/datastax/cloud/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
_HAS_SSL = True
2424
try:
25-
from ssl import SSLContext, PROTOCOL_TLS, CERT_REQUIRED
25+
from ssl import SSLContext, PROTOCOL_TLS_CLIENT, CERT_REQUIRED
2626
except:
2727
_HAS_SSL = False
2828

@@ -169,7 +169,7 @@ def parse_metadata_info(config, http_data):
169169

170170

171171
def _ssl_context_from_cert(ca_cert_location, cert_location, key_location):
172-
ssl_context = SSLContext(PROTOCOL_TLS)
172+
ssl_context = SSLContext(PROTOCOL_TLS_CLIENT)
173173
ssl_context.load_verify_locations(ca_cert_location)
174174
ssl_context.verify_mode = CERT_REQUIRED
175175
ssl_context.load_cert_chain(certfile=cert_location, keyfile=key_location)

cassandra/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from cassandra import DriverException
4242

4343
DATETIME_EPOC = datetime.datetime(1970, 1, 1)
44-
UTC_DATETIME_EPOC = datetime.datetime.utcfromtimestamp(0)
44+
UTC_DATETIME_EPOC = datetime.datetime.fromtimestamp(0, tz=datetime.timezone.utc)
4545

4646
_nan = float('nan')
4747

pytest.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,20 @@ log_format = %(asctime)s.%(msecs)03d %(levelname)s [%(module)s:%(lineno)s]: %(me
33
log_level = DEBUG
44
log_date_format = %Y-%m-%d %H:%M:%S
55
xfail_strict=true
6+
7+
filterwarnings =
8+
error
9+
ignore::pytest.PytestCollectionWarning
10+
ignore::ResourceWarning
11+
ignore:distutils Version classes are deprecated:DeprecationWarning:eventlet.support.greenlets
12+
ignore:X509Extension support in pyOpenSSL is deprecated.:DeprecationWarning
13+
ignore:CRL support in pyOpenSSL is deprecated:DeprecationWarning
14+
ignore:sign\(\) is deprecated:DeprecationWarning
15+
ignore:verify\(\) is deprecated:DeprecationWarning
16+
ignore:pkg_resources is deprecated as an API:DeprecationWarning:gevent.events
17+
ignore:.*pkg_resources.declare_namespace.*:DeprecationWarning
18+
ignore:"@coroutine" decorator is deprecated since Python 3.8:DeprecationWarning:asynctest.*
19+
ignore:The asyncore module is deprecated and will be removed in Python 3.12.*:DeprecationWarning
20+
ignore:CSR support in pyOpenSSL is deprecated.*:DeprecationWarning
21+
ignore:get_elliptic_curves is deprecated:DeprecationWarning
22+
ignore:get_elliptic_curve is deprecated:DeprecationWarning

tests/integration/cqlengine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def wrapped_function(*args, **kwargs):
7777
# DeMonkey Patch our code
7878
cassandra.cqlengine.connection.execute = original_function
7979
# Check to see if we have a pre-existing test case to work from.
80-
if len(args) is 0:
80+
if len(args) == 0:
8181
test_case = unittest.TestCase("__init__")
8282
else:
8383
test_case = args[0]

tests/integration/cqlengine/columns/test_counter_column.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ def tearDownClass(cls):
7878

7979
def test_updates(self):
8080
""" Tests that counter updates work as intended """
81-
instance = TestCounterModel.create()
81+
instance = TestCounterModel()
8282
instance.counter += 5
83-
instance.save()
83+
instance.update()
8484

8585
actual = TestCounterModel.get(partition=instance.partition)
8686
assert actual.counter == 5
@@ -103,7 +103,7 @@ def test_update_from_none(self):
103103
""" Tests that updating from None uses a create statement """
104104
instance = TestCounterModel()
105105
instance.counter += 1
106-
instance.save()
106+
instance.update()
107107

108108
new = TestCounterModel.get(partition=instance.partition)
109109
assert new.counter == 1
@@ -115,15 +115,15 @@ def test_new_instance_defaults_to_zero(self):
115115

116116
def test_save_after_no_update(self):
117117
expected_value = 15
118-
instance = TestCounterModel.create()
118+
instance = TestCounterModel()
119119
instance.update(counter=expected_value)
120120

121121
# read back
122122
instance = TestCounterModel.get(partition=instance.partition)
123123
self.assertEqual(instance.counter, expected_value)
124124

125125
# save after doing nothing
126-
instance.save()
126+
instance.update()
127127
self.assertEqual(instance.counter, expected_value)
128128

129129
# make sure there was no increment

tests/integration/cqlengine/connections/test_connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import unittest
16+
import pytest
1617

1718

1819
from cassandra import ConsistencyLevel
@@ -130,7 +131,8 @@ class ConnectionModel(Model):
130131
key = columns.Integer(primary_key=True)
131132
some_data = columns.Text()
132133

133-
134+
@pytest.mark.filterwarnings("ignore:Setting the consistency level at the session level will be removed")
135+
@pytest.mark.filterwarnings("ignore:Legacy execution parameters will be removed")
134136
class ConnectionInitTest(unittest.TestCase):
135137
def test_default_connection_uses_legacy(self):
136138
connection.default()

tests/integration/cqlengine/management/test_management.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import unittest
15+
import pytest
1516

1617
import mock
1718
import logging
@@ -381,6 +382,7 @@ class TestIndexSetModel(Model):
381382
mixed_tuple = columns.Tuple(columns.Text, columns.Integer, columns.Text, index=True)
382383

383384

385+
@pytest.mark.filterwarnings("ignore:Model __table_name_case_sensitive__ will be removed")
384386
class IndexTests(BaseCassEngTestCase):
385387

386388
def setUp(self):

tests/integration/cqlengine/model/test_model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import unittest
15+
import pytest
1516

1617
from mock import patch
1718

@@ -125,6 +126,7 @@ class TestModel(Model):
125126
# .. but we can still get the bare CF name
126127
self.assertEqual(TestModel.column_family_name(include_keyspace=False), "test_model")
127128

129+
@pytest.mark.filterwarnings("ignore:__table_name_case_sensitive__ will be removed")
128130
def test_column_family_case_sensitive(self):
129131
"""
130132
Test to ensure case sensitivity is honored when __table_name_case_sensitive__ flag is set

0 commit comments

Comments
 (0)