pytest: replace nose SkipTest with pytest.skip()

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 7e7e8d5a42)
This commit is contained in:
Casey Bodley 2023-01-21 13:37:40 -05:00 committed by Ali Maredia
parent e8d56603a3
commit 5396b04f1b
5 changed files with 27 additions and 34 deletions

View file

@ -21,7 +21,6 @@ from boto.s3.connection import S3Connection
from nose.tools import eq_ as eq from nose.tools import eq_ as eq
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
from .utils import assert_raises from .utils import assert_raises
@ -482,11 +481,11 @@ def test_bucket_create_bad_date_none_aws2():
def check_aws4_support(): def check_aws4_support():
if 'S3_USE_SIGV4' not in os.environ: if 'S3_USE_SIGV4' not in os.environ:
raise SkipTest pytest.skip('sigv4 tests not enabled by S3_USE_SIGV4')
def check_aws2_support(): def check_aws2_support():
if 'S3_USE_SIGV4' in os.environ: if 'S3_USE_SIGV4' in os.environ:
raise SkipTest pytest.skip('sigv2 tests disabled by S3_USE_SIGV4')
@tag('auth_aws4') @tag('auth_aws4')

View file

@ -30,7 +30,6 @@ from urllib.parse import urlparse
from nose.tools import eq_ as eq from nose.tools import eq_ as eq
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
from . import utils from . import utils
from .utils import assert_raises from .utils import assert_raises
@ -432,7 +431,7 @@ def lc_transitions(transitions=None):
def test_object_storage_class(): def test_object_storage_class():
sc = configured_storage_classes() sc = configured_storage_classes()
if len(sc) < 2: if len(sc) < 2:
raise SkipTest pytest.skip('requires multiple storage classes')
bucket = get_new_bucket() bucket = get_new_bucket()
@ -454,7 +453,7 @@ def test_object_storage_class():
def test_object_storage_class_multipart(): def test_object_storage_class_multipart():
sc = configured_storage_classes() sc = configured_storage_classes()
if len(sc) < 2: if len(sc) < 2:
raise SkipTest pytest.skip('requires multiple storage classes')
bucket = get_new_bucket() bucket = get_new_bucket()
size = 11 * 1024 * 1024 size = 11 * 1024 * 1024
@ -470,7 +469,7 @@ def test_object_storage_class_multipart():
def _do_test_object_modify_storage_class(obj_write_func, size): def _do_test_object_modify_storage_class(obj_write_func, size):
sc = configured_storage_classes() sc = configured_storage_classes()
if len(sc) < 2: if len(sc) < 2:
raise SkipTest pytest.skip('requires multiple storage classes')
bucket = get_new_bucket() bucket = get_new_bucket()
@ -515,7 +514,7 @@ def test_object_modify_storage_class_multipart():
def _do_test_object_storage_class_copy(obj_write_func, size): def _do_test_object_storage_class_copy(obj_write_func, size):
sc = configured_storage_classes() sc = configured_storage_classes()
if len(sc) < 2: if len(sc) < 2:
raise SkipTest pytest.skip('requires multiple storage classes')
src_bucket = get_new_bucket() src_bucket = get_new_bucket()
dest_bucket = get_new_bucket() dest_bucket = get_new_bucket()

View file

@ -15,7 +15,6 @@ from urllib.parse import urlparse
from nose.tools import eq_ as eq, ok_ as ok from nose.tools import eq_ as eq, ok_ as ok
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from nose.tools import timed from nose.tools import timed
from nose.plugins.skip import SkipTest
from .. import common from .. import common
@ -56,13 +55,12 @@ def check_can_test_website():
if e.status == 404 and e.reason == 'Not Found' and e.error_code in ['NoSuchWebsiteConfiguration', 'NoSuchKey']: if e.status == 404 and e.reason == 'Not Found' and e.error_code in ['NoSuchWebsiteConfiguration', 'NoSuchKey']:
return True return True
elif e.status == 405 and e.reason == 'Method Not Allowed' and e.error_code == 'MethodNotAllowed': elif e.status == 405 and e.reason == 'Method Not Allowed' and e.error_code == 'MethodNotAllowed':
# rgw_enable_static_website is false pytest.skip('rgw_enable_static_website is false')
raise SkipTest
elif e.status == 403 and e.reason == 'SignatureDoesNotMatch' and e.error_code == 'Forbidden': elif e.status == 403 and e.reason == 'SignatureDoesNotMatch' and e.error_code == 'Forbidden':
# This is older versions that do not support the website code # This is older versions that do not support the website code
raise SkipTest pytest.skip('static website is not implemented')
elif e.status == 501 and e.error_code == 'NotImplemented': elif e.status == 501 and e.error_code == 'NotImplemented':
raise SkipTest pytest.skip('static website is not implemented')
else: else:
raise RuntimeError("Unknown response in checking if WebsiteConf is supported", e) raise RuntimeError("Unknown response in checking if WebsiteConf is supported", e)
finally: finally:

View file

@ -4,7 +4,6 @@ from botocore.exceptions import ClientError
from botocore.exceptions import ParamValidationError from botocore.exceptions import ParamValidationError
from nose.tools import eq_ as eq from nose.tools import eq_ as eq
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
import isodate import isodate
import email.utils import email.utils
import datetime import datetime
@ -4440,7 +4439,7 @@ def test_bucket_create_exists():
def test_bucket_get_location(): def test_bucket_get_location():
location_constraint = get_main_api_name() location_constraint = get_main_api_name()
if not location_constraint: if not location_constraint:
raise SkipTest pytest.skip('no api_name configured')
bucket_name = get_new_bucket_name() bucket_name = get_new_bucket_name()
client = get_client() client = get_client()
@ -10230,7 +10229,7 @@ def _test_encryption_sse_customer_write(file_size):
def test_lifecycle_transition(): def test_lifecycle_transition():
sc = configured_storage_classes() sc = configured_storage_classes()
if len(sc) < 3: if len(sc) < 3:
raise SkipTest pytest.skip('requires 3 or more storage classes')
bucket_name = _create_objects(keys=['expire1/foo', 'expire1/bar', 'keep2/foo', bucket_name = _create_objects(keys=['expire1/foo', 'expire1/bar', 'keep2/foo',
'keep2/bar', 'expire3/foo', 'expire3/bar']) 'keep2/bar', 'expire3/foo', 'expire3/bar'])
@ -10281,7 +10280,7 @@ def test_lifecycle_transition():
def test_lifecycle_transition_single_rule_multi_trans(): def test_lifecycle_transition_single_rule_multi_trans():
sc = configured_storage_classes() sc = configured_storage_classes()
if len(sc) < 3: if len(sc) < 3:
raise SkipTest pytest.skip('requires 3 or more storage classes')
bucket_name = _create_objects(keys=['expire1/foo', 'expire1/bar', 'keep2/foo', bucket_name = _create_objects(keys=['expire1/foo', 'expire1/bar', 'keep2/foo',
'keep2/bar', 'expire3/foo', 'expire3/bar']) 'keep2/bar', 'expire3/foo', 'expire3/bar'])
@ -10328,7 +10327,7 @@ def test_lifecycle_transition_single_rule_multi_trans():
def test_lifecycle_set_noncurrent_transition(): def test_lifecycle_set_noncurrent_transition():
sc = configured_storage_classes() sc = configured_storage_classes()
if len(sc) < 3: if len(sc) < 3:
raise SkipTest pytest.skip('requires 3 or more storage classes')
bucket = get_new_bucket() bucket = get_new_bucket()
client = get_client() client = get_client()
@ -10373,7 +10372,7 @@ def test_lifecycle_set_noncurrent_transition():
def test_lifecycle_noncur_transition(): def test_lifecycle_noncur_transition():
sc = configured_storage_classes() sc = configured_storage_classes()
if len(sc) < 3: if len(sc) < 3:
raise SkipTest pytest.skip('requires 3 or more storage classes')
bucket = get_new_bucket() bucket = get_new_bucket()
client = get_client() client = get_client()
@ -10460,7 +10459,7 @@ def verify_object(client, bucket, key, content=None, sc=None):
def test_lifecycle_cloud_transition(): def test_lifecycle_cloud_transition():
cloud_sc = get_cloud_storage_class() cloud_sc = get_cloud_storage_class()
if cloud_sc == None: if cloud_sc == None:
raise SkipTest pytest.skip('no cloud_storage_class configured')
retain_head_object = get_cloud_retain_head_object() retain_head_object = get_cloud_retain_head_object()
target_path = get_cloud_target_path() target_path = get_cloud_target_path()
@ -10550,7 +10549,7 @@ def test_lifecycle_cloud_transition():
def test_lifecycle_cloud_multiple_transition(): def test_lifecycle_cloud_multiple_transition():
cloud_sc = get_cloud_storage_class() cloud_sc = get_cloud_storage_class()
if cloud_sc == None: if cloud_sc == None:
raise SkipTest pytest.skip('[s3 cloud] section missing cloud_storage_class')
retain_head_object = get_cloud_retain_head_object() retain_head_object = get_cloud_retain_head_object()
target_path = get_cloud_target_path() target_path = get_cloud_target_path()
@ -10559,7 +10558,7 @@ def test_lifecycle_cloud_multiple_transition():
sc1 = get_cloud_regular_storage_class() sc1 = get_cloud_regular_storage_class()
if (sc1 == None): if (sc1 == None):
raise SkipTest pytest.skip('[s3 cloud] section missing storage_class')
sc = ['STANDARD', sc1, cloud_sc] sc = ['STANDARD', sc1, cloud_sc]
@ -10623,16 +10622,15 @@ def test_lifecycle_cloud_multiple_transition():
def test_lifecycle_noncur_cloud_transition(): def test_lifecycle_noncur_cloud_transition():
cloud_sc = get_cloud_storage_class() cloud_sc = get_cloud_storage_class()
if cloud_sc == None: if cloud_sc == None:
raise SkipTest pytest.skip('[s3 cloud] section missing cloud_storage_class')
retain_head_object = get_cloud_retain_head_object() retain_head_object = get_cloud_retain_head_object()
target_path = get_cloud_target_path() target_path = get_cloud_target_path()
target_sc = get_cloud_target_storage_class() target_sc = get_cloud_target_storage_class()
sc1 = get_cloud_regular_storage_class() sc1 = get_cloud_regular_storage_class()
if (sc1 == None): if (sc1 == None):
raise SkipTest pytest.skip('[s3 cloud] section missing storage_class')
sc = ['STANDARD', sc1, cloud_sc] sc = ['STANDARD', sc1, cloud_sc]
@ -10720,7 +10718,7 @@ def test_lifecycle_noncur_cloud_transition():
def test_lifecycle_cloud_transition_large_obj(): def test_lifecycle_cloud_transition_large_obj():
cloud_sc = get_cloud_storage_class() cloud_sc = get_cloud_storage_class()
if cloud_sc == None: if cloud_sc == None:
raise SkipTest pytest.skip('[s3 cloud] section missing cloud_storage_class')
retain_head_object = get_cloud_retain_head_object() retain_head_object = get_cloud_retain_head_object()
target_path = get_cloud_target_path() target_path = get_cloud_target_path()
@ -11585,7 +11583,7 @@ def test_sse_kms_post_object_authenticated_request():
def test_sse_kms_transfer_1b(): def test_sse_kms_transfer_1b():
kms_keyid = get_main_kms_keyid() kms_keyid = get_main_kms_keyid()
if kms_keyid is None: if kms_keyid is None:
raise SkipTest pytest.skip('[s3 main] section missing kms_keyid')
_test_sse_kms_customer_write(1, key_id = kms_keyid) _test_sse_kms_customer_write(1, key_id = kms_keyid)
@ -11600,7 +11598,7 @@ def test_sse_kms_transfer_1b():
def test_sse_kms_transfer_1kb(): def test_sse_kms_transfer_1kb():
kms_keyid = get_main_kms_keyid() kms_keyid = get_main_kms_keyid()
if kms_keyid is None: if kms_keyid is None:
raise SkipTest pytest.skip('[s3 main] section missing kms_keyid')
_test_sse_kms_customer_write(1024, key_id = kms_keyid) _test_sse_kms_customer_write(1024, key_id = kms_keyid)
@ -11615,7 +11613,7 @@ def test_sse_kms_transfer_1kb():
def test_sse_kms_transfer_1MB(): def test_sse_kms_transfer_1MB():
kms_keyid = get_main_kms_keyid() kms_keyid = get_main_kms_keyid()
if kms_keyid is None: if kms_keyid is None:
raise SkipTest pytest.skip('[s3 main] section missing kms_keyid')
_test_sse_kms_customer_write(1024*1024, key_id = kms_keyid) _test_sse_kms_customer_write(1024*1024, key_id = kms_keyid)
@ -11630,7 +11628,7 @@ def test_sse_kms_transfer_1MB():
def test_sse_kms_transfer_13b(): def test_sse_kms_transfer_13b():
kms_keyid = get_main_kms_keyid() kms_keyid = get_main_kms_keyid()
if kms_keyid is None: if kms_keyid is None:
raise SkipTest pytest.skip('[s3 main] section missing kms_keyid')
_test_sse_kms_customer_write(13, key_id = kms_keyid) _test_sse_kms_customer_write(13, key_id = kms_keyid)
@ -13268,7 +13266,7 @@ def test_bucket_policy_put_obj_s3_kms():
def test_bucket_policy_put_obj_kms_noenc(): def test_bucket_policy_put_obj_kms_noenc():
kms_keyid = get_main_kms_keyid() kms_keyid = get_main_kms_keyid()
if kms_keyid is None: if kms_keyid is None:
raise SkipTest pytest.skip('[s3 main] section missing kms_keyid')
bucket_name = get_new_bucket() bucket_name = get_new_bucket()
client = get_v2_client() client = get_v2_client()
@ -15032,7 +15030,7 @@ def _test_sse_kms_default_upload(file_size):
""" """
kms_keyid = get_main_kms_keyid() kms_keyid = get_main_kms_keyid()
if kms_keyid is None: if kms_keyid is None:
raise SkipTest pytest.skip('[s3 main] section missing kms_keyid')
bucket_name = get_new_bucket() bucket_name = get_new_bucket()
client = get_client() client = get_client()
_put_bucket_encryption_kms(client, bucket_name) _put_bucket_encryption_kms(client, bucket_name)
@ -15265,7 +15263,7 @@ def test_sse_s3_default_post_object_authenticated_request():
def test_sse_kms_default_post_object_authenticated_request(): def test_sse_kms_default_post_object_authenticated_request():
kms_keyid = get_main_kms_keyid() kms_keyid = get_main_kms_keyid()
if kms_keyid is None: if kms_keyid is None:
raise SkipTest pytest.skip('[s3 main] section missing kms_keyid')
bucket_name = get_new_bucket() bucket_name = get_new_bucket()
client = get_client() client = get_client()
_put_bucket_encryption_kms(client, bucket_name) _put_bucket_encryption_kms(client, bucket_name)

View file

@ -4,7 +4,6 @@ from botocore.exceptions import ClientError
from botocore.exceptions import ParamValidationError from botocore.exceptions import ParamValidationError
from nose.tools import eq_ as eq from nose.tools import eq_ as eq
from nose.plugins.attrib import attr from nose.plugins.attrib import attr
from nose.plugins.skip import SkipTest
import pytest import pytest
import isodate import isodate
import email.utils import email.utils