convert cqlshlib from nose to pytest

Patch by brandonwilliams; reviewed by bereng for CASSANDRA-18088
This commit is contained in:
Brandon Williams 2022-12-16 12:29:57 -06:00
parent 563a26c6b1
commit f6933a0419
5 changed files with 11 additions and 10 deletions

View File

@ -129,7 +129,7 @@ ccm start --wait-for-binary-proto
cd ${CASSANDRA_DIR}/pylib/cqlshlib/
set +e # disable immediate exit from this point
nosetests
pytest
RETURN="$?"
ccm remove

View File

@ -20,7 +20,7 @@ import io
import os.path
import random
import string
from nose.tools import nottest
import pytest
from .basecase import TEST_HOST, TEST_PORT, cql, cqlsh, cqlshlog, policy, quote_name, test_dir
from .run_cqlsh import run_cqlsh, call_cqlsh
@ -152,7 +152,7 @@ def cql_rule_set():
class DEFAULTVAL: pass
@nottest
@pytest.mark.skip(reason="not a test")
def testrun_cqlsh(keyspace=DEFAULTVAL, **kwargs):
# use a positive default sentinel so that keyspace=None can be used
# to override the default behavior
@ -161,7 +161,7 @@ def testrun_cqlsh(keyspace=DEFAULTVAL, **kwargs):
return run_cqlsh(keyspace=keyspace, **kwargs)
@nottest
@pytest.mark.skip(reason="not a test")
def testcall_cqlsh(keyspace=None, **kwargs):
if keyspace is None:
keyspace = get_keyspace()

View File

@ -17,11 +17,11 @@
from cassandra.policies import SimpleConvictionPolicy
from cassandra.pool import Host
from cqlshlib.sslhandling import ssl_settings
from nose.tools import assert_raises
import unittest
import os
import ssl
import pytest
class SslSettingsTest(unittest.TestCase):
@ -53,7 +53,7 @@ class SslSettingsTest(unittest.TestCase):
def test_invalid_ssl_versions_from_env(self):
msg = "invalid_ssl is not a valid SSL protocol, please use one of TLSv1, TLSv1_1, or TLSv1_2"
with assert_raises(SystemExit) as error:
with pytest.raises(SystemExit) as error:
self._test_ssl_version_from_env('invalid_ssl')
assert msg == error.exception.message
@ -69,7 +69,7 @@ class SslSettingsTest(unittest.TestCase):
def test_invalid_ssl_version_config(self):
msg = "invalid_ssl is not a valid SSL protocol, please use one of TLSv1, TLSv1_1, or TLSv1_2"
with assert_raises(SystemExit) as error:
with pytest.raises(SystemExit) as error:
ssl_settings(self.host, os.path.join('test', 'config', 'sslhandling_invalid.config'))
assert msg in error.exception.message

2
pylib/pytest.ini Normal file
View File

@ -0,0 +1,2 @@
[pytest]
addopts = --junit-xml=nosetests.xml

View File

@ -11,8 +11,7 @@ docopt
enum34
flaky
mock
nose
nose-test-select
pytest
parse
pycodestyle
psutil