From 7e7e8d5a4237414d7cec891fbb6573215a236597 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Sat, 21 Jan 2023 13:37:40 -0500 Subject: [PATCH] pytest: replace nose SkipTest with pytest.skip() Signed-off-by: Casey Bodley --- s3tests/functional/test_headers.py | 5 ++-- s3tests/functional/test_s3.py | 9 +++---- s3tests/functional/test_s3_website.py | 8 +++--- s3tests_boto3/functional/test_s3.py | 38 +++++++++++++-------------- s3tests_boto3/functional/test_sts.py | 1 - 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/s3tests/functional/test_headers.py b/s3tests/functional/test_headers.py index ecc90ae..eb3090c 100644 --- a/s3tests/functional/test_headers.py +++ b/s3tests/functional/test_headers.py @@ -21,7 +21,6 @@ from boto.s3.connection import S3Connection from nose.tools import eq_ as eq from nose.plugins.attrib import attr -from nose.plugins.skip import SkipTest from .utils import assert_raises @@ -482,11 +481,11 @@ def test_bucket_create_bad_date_none_aws2(): def check_aws4_support(): if 'S3_USE_SIGV4' not in os.environ: - raise SkipTest + pytest.skip('sigv4 tests not enabled by S3_USE_SIGV4') def check_aws2_support(): if 'S3_USE_SIGV4' in os.environ: - raise SkipTest + pytest.skip('sigv2 tests disabled by S3_USE_SIGV4') @tag('auth_aws4') diff --git a/s3tests/functional/test_s3.py b/s3tests/functional/test_s3.py index 5fca0ca..b15d6a2 100644 --- a/s3tests/functional/test_s3.py +++ b/s3tests/functional/test_s3.py @@ -30,7 +30,6 @@ from urllib.parse import urlparse from nose.tools import eq_ as eq from nose.plugins.attrib import attr -from nose.plugins.skip import SkipTest from . import utils from .utils import assert_raises @@ -432,7 +431,7 @@ def lc_transitions(transitions=None): def test_object_storage_class(): sc = configured_storage_classes() if len(sc) < 2: - raise SkipTest + pytest.skip('requires multiple storage classes') bucket = get_new_bucket() @@ -454,7 +453,7 @@ def test_object_storage_class(): def test_object_storage_class_multipart(): sc = configured_storage_classes() if len(sc) < 2: - raise SkipTest + pytest.skip('requires multiple storage classes') bucket = get_new_bucket() 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): sc = configured_storage_classes() if len(sc) < 2: - raise SkipTest + pytest.skip('requires multiple storage classes') 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): sc = configured_storage_classes() if len(sc) < 2: - raise SkipTest + pytest.skip('requires multiple storage classes') src_bucket = get_new_bucket() dest_bucket = get_new_bucket() diff --git a/s3tests/functional/test_s3_website.py b/s3tests/functional/test_s3_website.py index 7d5cd99..4d3b110 100644 --- a/s3tests/functional/test_s3_website.py +++ b/s3tests/functional/test_s3_website.py @@ -15,7 +15,6 @@ from urllib.parse import urlparse from nose.tools import eq_ as eq, ok_ as ok from nose.plugins.attrib import attr from nose.tools import timed -from nose.plugins.skip import SkipTest 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']: return True elif e.status == 405 and e.reason == 'Method Not Allowed' and e.error_code == 'MethodNotAllowed': - # rgw_enable_static_website is false - raise SkipTest + pytest.skip('rgw_enable_static_website is false') elif e.status == 403 and e.reason == 'SignatureDoesNotMatch' and e.error_code == 'Forbidden': # 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': - raise SkipTest + pytest.skip('static website is not implemented') else: raise RuntimeError("Unknown response in checking if WebsiteConf is supported", e) finally: diff --git a/s3tests_boto3/functional/test_s3.py b/s3tests_boto3/functional/test_s3.py index 665528a..c3d8148 100644 --- a/s3tests_boto3/functional/test_s3.py +++ b/s3tests_boto3/functional/test_s3.py @@ -4,7 +4,6 @@ from botocore.exceptions import ClientError from botocore.exceptions import ParamValidationError from nose.tools import eq_ as eq from nose.plugins.attrib import attr -from nose.plugins.skip import SkipTest import isodate import email.utils import datetime @@ -4440,7 +4439,7 @@ def test_bucket_create_exists(): def test_bucket_get_location(): location_constraint = get_main_api_name() if not location_constraint: - raise SkipTest + pytest.skip('no api_name configured') bucket_name = get_new_bucket_name() client = get_client() @@ -10230,7 +10229,7 @@ def _test_encryption_sse_customer_write(file_size): def test_lifecycle_transition(): sc = configured_storage_classes() 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', 'keep2/bar', 'expire3/foo', 'expire3/bar']) @@ -10281,7 +10280,7 @@ def test_lifecycle_transition(): def test_lifecycle_transition_single_rule_multi_trans(): sc = configured_storage_classes() 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', 'keep2/bar', 'expire3/foo', 'expire3/bar']) @@ -10328,7 +10327,7 @@ def test_lifecycle_transition_single_rule_multi_trans(): def test_lifecycle_set_noncurrent_transition(): sc = configured_storage_classes() if len(sc) < 3: - raise SkipTest + pytest.skip('requires 3 or more storage classes') bucket = get_new_bucket() client = get_client() @@ -10373,7 +10372,7 @@ def test_lifecycle_set_noncurrent_transition(): def test_lifecycle_noncur_transition(): sc = configured_storage_classes() if len(sc) < 3: - raise SkipTest + pytest.skip('requires 3 or more storage classes') bucket = get_new_bucket() client = get_client() @@ -10460,7 +10459,7 @@ def verify_object(client, bucket, key, content=None, sc=None): def test_lifecycle_cloud_transition(): cloud_sc = get_cloud_storage_class() if cloud_sc == None: - raise SkipTest + pytest.skip('no cloud_storage_class configured') retain_head_object = get_cloud_retain_head_object() target_path = get_cloud_target_path() @@ -10550,7 +10549,7 @@ def test_lifecycle_cloud_transition(): def test_lifecycle_cloud_multiple_transition(): cloud_sc = get_cloud_storage_class() if cloud_sc == None: - raise SkipTest + pytest.skip('[s3 cloud] section missing cloud_storage_class') retain_head_object = get_cloud_retain_head_object() target_path = get_cloud_target_path() @@ -10559,7 +10558,7 @@ def test_lifecycle_cloud_multiple_transition(): sc1 = get_cloud_regular_storage_class() if (sc1 == None): - raise SkipTest + pytest.skip('[s3 cloud] section missing storage_class') sc = ['STANDARD', sc1, cloud_sc] @@ -10623,16 +10622,15 @@ def test_lifecycle_cloud_multiple_transition(): def test_lifecycle_noncur_cloud_transition(): cloud_sc = get_cloud_storage_class() if cloud_sc == None: - raise SkipTest + pytest.skip('[s3 cloud] section missing cloud_storage_class') retain_head_object = get_cloud_retain_head_object() target_path = get_cloud_target_path() target_sc = get_cloud_target_storage_class() sc1 = get_cloud_regular_storage_class() - if (sc1 == None): - raise SkipTest + pytest.skip('[s3 cloud] section missing storage_class') sc = ['STANDARD', sc1, cloud_sc] @@ -10720,7 +10718,7 @@ def test_lifecycle_noncur_cloud_transition(): def test_lifecycle_cloud_transition_large_obj(): cloud_sc = get_cloud_storage_class() if cloud_sc == None: - raise SkipTest + pytest.skip('[s3 cloud] section missing cloud_storage_class') retain_head_object = get_cloud_retain_head_object() target_path = get_cloud_target_path() @@ -11585,7 +11583,7 @@ def test_sse_kms_post_object_authenticated_request(): def test_sse_kms_transfer_1b(): kms_keyid = get_main_kms_keyid() 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) @@ -11600,7 +11598,7 @@ def test_sse_kms_transfer_1b(): def test_sse_kms_transfer_1kb(): kms_keyid = get_main_kms_keyid() 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) @@ -11615,7 +11613,7 @@ def test_sse_kms_transfer_1kb(): def test_sse_kms_transfer_1MB(): kms_keyid = get_main_kms_keyid() 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) @@ -11630,7 +11628,7 @@ def test_sse_kms_transfer_1MB(): def test_sse_kms_transfer_13b(): kms_keyid = get_main_kms_keyid() 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) @@ -13268,7 +13266,7 @@ def test_bucket_policy_put_obj_s3_kms(): def test_bucket_policy_put_obj_kms_noenc(): kms_keyid = get_main_kms_keyid() if kms_keyid is None: - raise SkipTest + pytest.skip('[s3 main] section missing kms_keyid') bucket_name = get_new_bucket() client = get_v2_client() @@ -15032,7 +15030,7 @@ def _test_sse_kms_default_upload(file_size): """ kms_keyid = get_main_kms_keyid() if kms_keyid is None: - raise SkipTest + pytest.skip('[s3 main] section missing kms_keyid') bucket_name = get_new_bucket() client = get_client() _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(): kms_keyid = get_main_kms_keyid() if kms_keyid is None: - raise SkipTest + pytest.skip('[s3 main] section missing kms_keyid') bucket_name = get_new_bucket() client = get_client() _put_bucket_encryption_kms(client, bucket_name) diff --git a/s3tests_boto3/functional/test_sts.py b/s3tests_boto3/functional/test_sts.py index 1f8bbdc..f926403 100644 --- a/s3tests_boto3/functional/test_sts.py +++ b/s3tests_boto3/functional/test_sts.py @@ -4,7 +4,6 @@ from botocore.exceptions import ClientError from botocore.exceptions import ParamValidationError from nose.tools import eq_ as eq from nose.plugins.attrib import attr -from nose.plugins.skip import SkipTest import pytest import isodate import email.utils