Bug: Fix pytest deprecations in cqlsh tests
Status: Resolved
Priority: Normal
Resolution: Fixed
Created: 07/Sep/23 02:36
Resolved: 27/Sep/23 18:44

Pytest reports several warnings regarding deprecated packages or methods:

 
{noformat}
 
../../../../../usr/local/lib/python3.10/site-packages/eventlet/support/greenlets.py:6
  /usr/local/lib/python3.10/site-packages/eventlet/support/greenlets.py:6: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    preserves_excinfo = (distutils.version.LooseVersion(greenlet.__version__)
 
../../../../../usr/local/lib/python3.10/site-packages/eventlet/support/greenlets.py:7
  /usr/local/lib/python3.10/site-packages/eventlet/support/greenlets.py:7: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
    >= distutils.version.LooseVersion('0.3.2'))
 
../../../../../usr/local/lib/python3.10/site-packages/cassandra/io/asyncorereactor.py:34
  /usr/local/lib/python3.10/site-packages/cassandra/io/asyncorereactor.py:34: DeprecationWarning: The asyncore module is deprecated and will be removed in Python 3.12. The recommended replacement is asyncio
    import asyncore
 
cqlshlib/test/test_copyutil.py: 42 warnings
  /Users/brad/Cassandra/cassandra/pylib/cqlshlib/copyutil.py:147: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead
    feeding_thread.setDaemon(True)
 
cqlshlib/test/test_cqlsh_completion.py::testrun_cqlsh
  /usr/local/lib/python3.10/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cqlshlib/test/test_cqlsh_completion.py::testrun_cqlsh returned <contextlib.closing object at 0x126dbc460>, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(
 
cqlshlib/test/test_cqlsh_output.py::testcall_cqlsh
  /usr/local/lib/python3.10/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cqlshlib/test/test_cqlsh_output.py::testcall_cqlsh returned ('\nNotice: Credentials in the cqlshrc file is deprecated and will be ignored in the future.\nPlease use a credentials file to specify the username and password.\n\nWARNING: cqlsh was built against 5.1, but this server is 4.1..  All features may not work!\n', 0), which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(
 
cqlshlib/test/test_cqlsh_output.py::testrun_cqlsh
  /usr/local/lib/python3.10/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cqlshlib/test/test_cqlsh_output.py::testrun_cqlsh returned <contextlib.closing object at 0x12710c520>, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(
 
cqlshlib/test/test_unicode.py::testrun_cqlsh
  /usr/local/lib/python3.10/site-packages/_pytest/python.py:198: PytestReturnNotNoneWarning: Expected None, but cqlshlib/test/test_unicode.py::testrun_cqlsh returned <contextlib.closing object at 0x126c93700>, which will be an error in a future version of pytest.  Did you mean to use `assert` instead of `return`?
    warnings.warn(
{noformat}
 

Resolution:
 * distutils Version class is used in cassandra-cql-tests.sh and was introduced in Cassandra [3.11.4 title|[https://github.com/apache/cassandra/blob/cassandra-3.11.4/pylib/cassandra-cqlsh-tests.sh].] It appears to be checking that the version used by ccm is > 3.8 to enable cdc.  Thus the code block can be dropped now in > 4.x.
 * Renamed testrun_cqlsh() to cqlsh_testrun() to avoid being picked up as a pytest

Out of scope:
 * DeprecationWarning: distutils Version from greenlets.py appears to be eventlet issue *[#763|https://github.com/eventlet/eventlet/issues/763]*
 * DeprecationWarning: The asyncore module from asyncorereactor.py appears to come from the eventlet issue [#804|https://github.com/eventlet/eventlet/issues/804]