This is an automated email from the ASF dual-hosted git repository.
smiklosovic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git
The following commit(s) were added to refs/heads/trunk by this push:
new 60314f2d6a Resolve deprecations in pylib
60314f2d6a is described below
commit 60314f2d6a03b6226e37b0d9daf67f1b4204ad5c
Author: Brad Schoening <[email protected]>
AuthorDate: Wed Sep 27 11:17:15 2023 -0400
Resolve deprecations in pylib
patch by Brad Schoening; reviewed by Stefan Miklosovic and Brandon Williams
for CASSANDRA-18827
---
pylib/cassandra-cqlsh-tests.sh | 18 +----------
pylib/cqlshlib/copyutil.py | 2 +-
pylib/cqlshlib/test/cassconnect.py | 6 ++--
pylib/cqlshlib/test/test_cqlsh_completion.py | 4 +--
pylib/cqlshlib/test/test_cqlsh_output.py | 46 ++++++++++++++--------------
pylib/cqlshlib/test/test_unicode.py | 10 +++---
pylib/setup.py | 2 +-
7 files changed, 35 insertions(+), 53 deletions(-)
diff --git a/pylib/cassandra-cqlsh-tests.sh b/pylib/cassandra-cqlsh-tests.sh
index 71bb4a10ea..758a9ec615 100755
--- a/pylib/cassandra-cqlsh-tests.sh
+++ b/pylib/cassandra-cqlsh-tests.sh
@@ -84,23 +84,7 @@ fi
ccm remove test || true # in case an old ccm cluster is left behind
ccm create test -n 1 --install-dir=${CASSANDRA_DIR}
ccm updateconf "user_defined_functions_enabled: true"
-
-version_from_build=$(ccm node1 versionfrombuild)
-export pre_or_post_cdc=$(python -c """from distutils.version import
LooseVersion
-print (\"postcdc\" if LooseVersion(\"${version_from_build}\") >= \"3.8\" else
\"precdc\")
-""")
-case "${pre_or_post_cdc}" in
- postcdc)
- ccm updateconf "cdc_enabled: true"
- ;;
- precdc)
- :
- ;;
- *)
- echo "${pre_or_post_cdc}" is an invalid value.
- exit 1
- ;;
-esac
+ccm updateconf "cdc_enabled: true"
ccm start --wait-for-binary-proto
diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py
index 2a8a11d1bf..1183bddc88 100644
--- a/pylib/cqlshlib/copyutil.py
+++ b/pylib/cqlshlib/copyutil.py
@@ -144,7 +144,7 @@ class SendingChannel(object):
printmsg('%s: %s' % (e.__class__.__name__, e.message if
hasattr(e, 'message') else str(e)))
feeding_thread = threading.Thread(target=feed)
- feeding_thread.setDaemon(True)
+ feeding_thread.daemon = True
feeding_thread.start()
def send(self, obj):
diff --git a/pylib/cqlshlib/test/cassconnect.py
b/pylib/cqlshlib/test/cassconnect.py
index 0118e07799..3ed93e4197 100644
--- a/pylib/cqlshlib/test/cassconnect.py
+++ b/pylib/cqlshlib/test/cassconnect.py
@@ -161,8 +161,7 @@ class DEFAULTVAL:
pass
-__TEST__ = False
-def testrun_cqlsh(keyspace=DEFAULTVAL, **kwargs):
+def cqlsh_testrun(keyspace=DEFAULTVAL, **kwargs):
# use a positive default sentinel so that keyspace=None can be used
# to override the default behavior
if keyspace is DEFAULTVAL:
@@ -170,8 +169,7 @@ def testrun_cqlsh(keyspace=DEFAULTVAL, **kwargs):
return run_cqlsh(keyspace=keyspace, **kwargs)
-__TEST__ = False
-def testcall_cqlsh(keyspace=None, **kwargs):
+def cqlsh_testcall(keyspace=None, **kwargs):
if keyspace is None:
keyspace = get_keyspace()
if 'input' in kwargs.keys() and isinstance(kwargs['input'], str):
diff --git a/pylib/cqlshlib/test/test_cqlsh_completion.py
b/pylib/cqlshlib/test/test_cqlsh_completion.py
index 2d01bdb0ae..ab00ea482c 100644
--- a/pylib/cqlshlib/test/test_cqlsh_completion.py
+++ b/pylib/cqlshlib/test/test_cqlsh_completion.py
@@ -22,7 +22,7 @@ import locale
import os
import re
from .basecase import BaseTestCase
-from .cassconnect import create_db, remove_db, testrun_cqlsh
+from .cassconnect import create_db, remove_db, cqlsh_testrun
from .run_cqlsh import TimeoutError
from cqlshlib.cql3handling import CqlRuleSet
@@ -54,7 +54,7 @@ class CqlshCompletionCase(BaseTestCase):
env['COLUMNS'] = '100000'
if (locale.getpreferredencoding() != 'UTF-8'):
env['LC_CTYPE'] = 'en_US.utf8'
- self.cqlsh_runner = testrun_cqlsh(cqlver=None, env=env)
+ self.cqlsh_runner = cqlsh_testrun(cqlver=None, env=env)
self.cqlsh = self.cqlsh_runner.__enter__()
def tearDown(self):
diff --git a/pylib/cqlshlib/test/test_cqlsh_output.py
b/pylib/cqlshlib/test/test_cqlsh_output.py
index 75f272b348..24af3bd965 100644
--- a/pylib/cqlshlib/test/test_cqlsh_output.py
+++ b/pylib/cqlshlib/test/test_cqlsh_output.py
@@ -26,7 +26,7 @@ from .basecase import (BaseTestCase, TEST_HOST, TEST_PORT,
at_a_time, cqlshlog, dedent)
from .cassconnect import (cassandra_cursor, create_db, get_keyspace,
quote_name, remove_db, split_cql_commands,
- testcall_cqlsh, testrun_cqlsh)
+ cqlsh_testcall, cqlsh_testrun)
from .ansi_colors import (ColoredText, ansi_seq, lookup_colorcode,
lookup_colorname, lookup_colorletter)
@@ -90,7 +90,7 @@ class TestCqlshOutput(BaseTestCase):
"""
if env is None:
env = self.default_env
- with testrun_cqlsh(tty=True, env=env, **kwargs) as c:
+ with cqlsh_testrun(tty=True, env=env, **kwargs) as c:
for query, expected in queries_and_expected_outputs:
cqlshlog.debug('Testing %r' % (query,))
output = c.cmd_and_response(query).lstrip("\r\n")
@@ -119,7 +119,7 @@ class TestCqlshOutput(BaseTestCase):
for termname in ('', 'dumb', 'vt100'):
cqlshlog.debug('TERM=%r' % termname)
env['TERM'] = termname
- with testrun_cqlsh(tty=True, env=env) as c:
+ with cqlsh_testrun(tty=True, env=env) as c:
c.send('select * from has_all_types;\n')
self.assertNoHasColors(c.read_to_next_prompt())
c.send('select count(*) from has_all_types;\n')
@@ -133,7 +133,7 @@ class TestCqlshOutput(BaseTestCase):
cqlshlog.debug('TERM=%r' % termname)
env['TERM'] = termname
query = 'select * from has_all_types limit 1;'
- output, result = testcall_cqlsh(prompt=None, env=env,
+ output, result = cqlsh_testcall(prompt=None, env=env,
tty=False, input=query + '\n')
output = output.splitlines()
for line in output:
@@ -154,7 +154,7 @@ class TestCqlshOutput(BaseTestCase):
cqlshlog.debug('TERM=%r' % termname)
env['TERMNAME'] = termname
env['TERM'] = termname
- with testrun_cqlsh(tty=True, env=env) as c:
+ with cqlsh_testrun(tty=True, env=env) as c:
c.send('select * from has_all_types;\n')
self.assertHasColors(c.read_to_next_prompt())
c.send('select count(*) from has_all_types;\n')
@@ -585,7 +585,7 @@ class TestCqlshOutput(BaseTestCase):
))
def test_prompt(self):
- with testrun_cqlsh(tty=True, keyspace=None, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, keyspace=None, env=self.default_env) as c:
self.assertTrue(c.output_header.splitlines()[-1].endswith('cqlsh>
'))
c.send('\n')
@@ -617,7 +617,7 @@ class TestCqlshOutput(BaseTestCase):
"RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR")
def test_describe_keyspace_output(self):
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
ks = get_keyspace()
qks = quote_name(ks)
for cmd in ('describe keyspace', 'desc keyspace'):
@@ -696,7 +696,7 @@ class TestCqlshOutput(BaseTestCase):
AND read_repair = 'BLOCKING'
AND speculative_retry = '99p';""" % quote_name(get_keyspace()))
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
for cmdword in ('describe table', 'desc columnfamily'):
for semicolon in (';', ''):
output = c.cmd_and_response('%s has_all_types%s' %
(cmdword, semicolon))
@@ -712,7 +712,7 @@ class TestCqlshOutput(BaseTestCase):
ks = get_keyspace()
- with testrun_cqlsh(tty=True, keyspace=None, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, keyspace=None, env=self.default_env) as c:
# when not in a keyspace
for cmdword in ('DESCRIBE COLUMNFAMILIES', 'desc tables'):
@@ -764,7 +764,7 @@ class TestCqlshOutput(BaseTestCase):
\n
'''
- with testrun_cqlsh(tty=True, keyspace=None, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, keyspace=None, env=self.default_env) as c:
# not in a keyspace
for semicolon in ('', ';'):
@@ -781,7 +781,7 @@ class TestCqlshOutput(BaseTestCase):
self.assertRegex(output, output_re + ringinfo_re + '$')
def test_describe_schema_output(self):
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
for semicolon in ('', ';'):
output = c.cmd_and_response('desc full schema' + semicolon)
self.assertNoHasColors(output)
@@ -792,7 +792,7 @@ class TestCqlshOutput(BaseTestCase):
self.assertRegex(output, r'.*\s*$')
def test_show_output(self):
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
output = c.cmd_and_response('show version;')
self.assertRegex(output,
r'^\[cqlsh \S+ \| Cassandra \S+ \| CQL spec \S+ \| Native
protocol \S+\]$')
@@ -803,7 +803,7 @@ class TestCqlshOutput(BaseTestCase):
% (re.escape(TEST_HOST),
TEST_PORT))
def test_eof_prints_newline(self):
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
c.send(CONTROL_D)
out = c.read_lines(1)[0].replace('\r', '')
self.assertEqual(out, '\n')
@@ -813,7 +813,7 @@ class TestCqlshOutput(BaseTestCase):
def test_exit_prints_no_newline(self):
for semicolon in ('', ';'):
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
cmd = 'exit%s\n' % semicolon
c.send(cmd)
out = c.read_lines(1)[0].replace('\r', '')
@@ -823,7 +823,7 @@ class TestCqlshOutput(BaseTestCase):
self.assertIn(type(cm.exception), (EOFError, OSError))
def test_help_types(self):
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
c.cmd_and_response('help types')
def test_help(self):
@@ -933,7 +933,7 @@ class TestCqlshOutput(BaseTestCase):
def test_expanded_output_counts_past_page(self):
query = "PAGING 5; EXPAND ON; SELECT * FROM twenty_rows_table;"
- output, result = testcall_cqlsh(prompt=None, env=self.default_env,
+ output, result = cqlsh_testcall(prompt=None, env=self.default_env,
tty=False, input=query)
self.assertEqual(0, result)
# format is "@ Row 1"
@@ -945,13 +945,13 @@ class TestCqlshOutput(BaseTestCase):
ks = get_keyspace()
query = "SELECT text_data FROM " + ks + ".escape_quotes;"
- output, result = testcall_cqlsh(prompt=None, env=self.default_env,
+ output, result = cqlsh_testcall(prompt=None, env=self.default_env,
tty=False, input=query)
self.assertEqual(0, result)
self.assertEqual(output.splitlines()[3].strip(), "I'm newb")
query = "SELECT map_data FROM " + ks + ".escape_quotes;"
- output, result = testcall_cqlsh(prompt=None, env=self.default_env,
+ output, result = cqlsh_testcall(prompt=None, env=self.default_env,
tty=False, input=query)
self.assertEqual(0, result)
self.assertEqual(output.splitlines()[3].strip(), "{1: 'I''m newb'}")
@@ -961,21 +961,21 @@ class TestCqlshOutput(BaseTestCase):
# Sets
query = "SELECT set_data FROM " + ks + ".escape_quotes;"
- output, result = testcall_cqlsh(prompt=None, env=self.default_env,
+ output, result = cqlsh_testcall(prompt=None, env=self.default_env,
tty=False, input=query)
self.assertEqual(0, result)
self.assertEqual(output.splitlines()[3].strip(), "{'I''m newb'}")
# Lists
query = "SELECT list_data FROM " + ks + ".escape_quotes;"
- output, result = testcall_cqlsh(prompt=None, env=self.default_env,
+ output, result = cqlsh_testcall(prompt=None, env=self.default_env,
tty=False, input=query)
self.assertEqual(0, result)
self.assertEqual(output.splitlines()[3].strip(), "['I''m newb']")
# Tuples
query = "SELECT tuple_data FROM " + ks + ".escape_quotes;"
- output, result = testcall_cqlsh(prompt=None, env=self.default_env,
+ output, result = cqlsh_testcall(prompt=None, env=self.default_env,
tty=False, input=query)
self.assertEqual(0, result)
self.assertEqual(output.splitlines()[3].strip(), "(1, 'I''m newb')")
@@ -984,7 +984,7 @@ class TestCqlshOutput(BaseTestCase):
ks = get_keyspace()
query = "SELECT udt_data FROM " + ks + ".escape_quotes;"
- output, result = testcall_cqlsh(prompt=None, env=self.default_env,
+ output, result = cqlsh_testcall(prompt=None, env=self.default_env,
tty=False, input=query)
self.assertEqual(0, result)
- self.assertEqual(output.splitlines()[3].strip(), "{data: 'I''m newb'}")
\ No newline at end of file
+ self.assertEqual(output.splitlines()[3].strip(), "{data: 'I''m newb'}")
diff --git a/pylib/cqlshlib/test/test_unicode.py
b/pylib/cqlshlib/test/test_unicode.py
index 9a2c7cc387..1f456768b8 100644
--- a/pylib/cqlshlib/test/test_unicode.py
+++ b/pylib/cqlshlib/test/test_unicode.py
@@ -18,7 +18,7 @@
import os
from .basecase import BaseTestCase
-from .cassconnect import (get_cassandra_connection, create_keyspace,
remove_db, testrun_cqlsh)
+from .cassconnect import (get_cassandra_connection, create_keyspace,
remove_db, cqlsh_testrun)
from cqlshlib.formatting import UNICODE_CONTROLCHARS_RE
@@ -40,7 +40,7 @@ class TestCqlshUnicode(BaseTestCase):
remove_db()
def test_unicode_value_round_trip(self):
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
value = 'ϑΉӁװڜ'
c.cmd_and_response("INSERT INTO t(k, v) VALUES (1, '%s');" %
(value,))
output = c.cmd_and_response('SELECT * FROM t;')
@@ -48,7 +48,7 @@ class TestCqlshUnicode(BaseTestCase):
def test_unicode_identifier(self):
col_name = 'テスト'
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
c.cmd_and_response('ALTER TABLE t ADD "%s" int;' % (col_name,))
# describe command reproduces name
output = c.cmd_and_response('DESC t')
@@ -59,7 +59,7 @@ class TestCqlshUnicode(BaseTestCase):
self.assertIn(col_name, output)
def test_unicode_multiline_input(self): # CASSANDRA-16400
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
value = '値'
c.send("INSERT INTO t(k, v) VALUES (1, \n'%s');\n" % (value,))
c.read_to_next_prompt()
@@ -67,7 +67,7 @@ class TestCqlshUnicode(BaseTestCase):
self.assertIn(value, output)
def test_unicode_desc(self): # CASSANDRA-16539
- with testrun_cqlsh(tty=True, env=self.default_env) as c:
+ with cqlsh_testrun(tty=True, env=self.default_env) as c:
v1 = 'ࠑ'
v2 = 'Ξ'
output = c.cmd_and_response('CREATE TYPE "%s" ( "%s" int );' %
(v1, v2))
diff --git a/pylib/setup.py b/pylib/setup.py
index 1dfd8cdc89..8fdca11e16 100755
--- a/pylib/setup.py
+++ b/pylib/setup.py
@@ -16,7 +16,7 @@
# limitations under the License.
import sys
-from distutils.core import setup
+from setuptools import setup
def get_extensions():
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]