diff --git a/test/functional/__init__.py b/test/functional/__init__.py index a17054cfeb..4654dc7933 100644 --- a/test/functional/__init__.py +++ b/test/functional/__init__.py @@ -33,6 +33,7 @@ from contextlib import closing from gzip import GzipFile from shutil import rmtree from tempfile import mkdtemp +from unittest import SkipTest from six.moves.configparser import ConfigParser, NoSectionError from six.moves import http_client @@ -47,10 +48,8 @@ from test import get_config, listen_zero from test.debug_logger import debug_logger from test.unit import FakeMemcache # importing skip_if_no_xattrs so that functional tests can grab it from the -# test.functional namespace. Importing SkipTest so this works under both -# nose and testr test runners. +# test.functional namespace. from test.unit import skip_if_no_xattrs as real_skip_if_no_xattrs -from test.unit import SkipTest from swift.common import constraints, utils, ring, storage_policy from swift.common.ring import Ring diff --git a/test/functional/s3api/__init__.py b/test/functional/s3api/__init__.py index 5be7fa1189..27d5602b0c 100644 --- a/test/functional/s3api/__init__.py +++ b/test/functional/s3api/__init__.py @@ -17,6 +17,8 @@ import unittest import traceback from contextlib import contextmanager import logging +from unittest import SkipTest + import test.functional as tf from test.functional.s3api.s3_test_client import ( Connection, get_boto3_conn, tear_down_s3) @@ -45,7 +47,7 @@ class S3ApiBase(unittest.TestCase): def setUp(self): if 's3api' not in tf.cluster_info: - raise tf.SkipTest('s3api middleware is not enabled') + raise SkipTest('s3api middleware is not enabled') if tf.config.get('account'): user_id = '%s:%s' % (tf.config['account'], tf.config['username']) else: @@ -82,7 +84,7 @@ class S3ApiBase(unittest.TestCase): class S3ApiBaseBoto3(S3ApiBase): def setUp(self): if 's3api' not in tf.cluster_info: - raise tf.SkipTest('s3api middleware is not enabled') + raise SkipTest('s3api middleware is not enabled') try: self.conn = get_boto3_conn( tf.config['s3_access_key'], tf.config['s3_secret_key']) diff --git a/test/functional/s3api/test_acl.py b/test/functional/s3api/test_acl.py index 7a3d4f98df..46c6298c3e 100644 --- a/test/functional/s3api/test_acl.py +++ b/test/functional/s3api/test_acl.py @@ -17,6 +17,7 @@ import unittest import os import test.functional as tf from swift.common.middleware.s3api.etree import fromstring +from unittest import SkipTest from test.functional.s3api import S3ApiBase from test.functional.s3api.s3_test_client import Connection from test.functional.s3api.utils import get_error_code @@ -37,7 +38,7 @@ class TestS3Acl(S3ApiBase): self.obj = 'object' if 's3_access_key3' not in tf.config or \ 's3_secret_key3' not in tf.config: - raise tf.SkipTest( + raise SkipTest( 'TestS3Acl requires s3_access_key3 and s3_secret_key3 ' 'configured for reduced-access user') status, headers, body = self.conn.make_request('PUT', self.bucket) diff --git a/test/functional/s3api/test_bucket.py b/test/functional/s3api/test_bucket.py index cbc558986f..ed0c411112 100644 --- a/test/functional/s3api/test_bucket.py +++ b/test/functional/s3api/test_bucket.py @@ -17,6 +17,7 @@ import botocore import datetime import unittest import os +from unittest import SkipTest import test.functional as tf from swift.common.utils import config_true_value @@ -123,7 +124,7 @@ class TestS3ApiBucket(S3ApiBaseBoto3): def test_bucket_listing_with_staticweb(self): if 'staticweb' not in tf.cluster_info: - raise tf.SkipTest('Staticweb not enabled') + raise SkipTest('Staticweb not enabled') bucket = 'bucket' resp = self.conn.create_bucket(Bucket=bucket) @@ -176,7 +177,7 @@ class TestS3ApiBucket(S3ApiBaseBoto3): if config_true_value(tf.cluster_info['s3api'].get('s3_acl')): if 's3_access_key2' not in tf.config or \ 's3_secret_key2' not in tf.config: - raise tf.SkipTest( + raise SkipTest( 'Cannot test for BucketAlreadyExists with second user; ' 'need s3_access_key2 and s3_secret_key2 configured') @@ -196,8 +197,8 @@ class TestS3ApiBucket(S3ApiBaseBoto3): def test_put_bucket_error_key3(self): if 's3_access_key3' not in tf.config or \ 's3_secret_key3' not in tf.config: - raise tf.SkipTest('Cannot test for AccessDenied; need ' - 's3_access_key3 and s3_secret_key3 configured') + raise SkipTest('Cannot test for AccessDenied; need ' + 's3_access_key3 and s3_secret_key3 configured') self.conn.create_bucket(Bucket='bucket') # If the user can't create buckets, they shouldn't even know diff --git a/test/functional/s3api/test_multi_upload.py b/test/functional/s3api/test_multi_upload.py index 1ff0b5e8b8..bdb17689be 100644 --- a/test/functional/s3api/test_multi_upload.py +++ b/test/functional/s3api/test_multi_upload.py @@ -52,7 +52,7 @@ class TestS3ApiMultiUpload(S3ApiBase): def setUp(self): super(TestS3ApiMultiUpload, self).setUp() if not tf.cluster_info['s3api'].get('allow_multipart_uploads', False): - raise tf.SkipTest('multipart upload is not enebled') + self.skipTest('multipart upload is not enebled') self.min_segment_size = int(tf.cluster_info['s3api'].get( 'min_segment_size', 5242880)) diff --git a/test/functional/s3api/test_versioning.py b/test/functional/s3api/test_versioning.py index bd80a95809..8d783ab61c 100644 --- a/test/functional/s3api/test_versioning.py +++ b/test/functional/s3api/test_versioning.py @@ -33,8 +33,8 @@ class TestS3ApiVersioning(S3ApiBase): super(TestS3ApiVersioning, self).setUp() if 'object_versioning' not in tf.cluster_info: # Alternatively, maybe we should assert we get 501s... - raise tf.SkipTest('S3 versioning requires that Swift object ' - 'versioning be enabled') + self.skipTest('S3 versioning requires that Swift object ' + 'versioning be enabled') status, headers, body = self.conn.make_request('PUT', 'bucket') self.assertEqual(status, 200) diff --git a/test/functional/test_dlo.py b/test/functional/test_dlo.py index d12a3654fc..1ce3512cd7 100644 --- a/test/functional/test_dlo.py +++ b/test/functional/test_dlo.py @@ -250,7 +250,7 @@ class TestDlo(Base): def test_dlo_referer_on_segment_container(self): if 'username3' not in tf.config: - raise tf.SkipTest('Requires user 3') + self.skipTest('Requires user 3') # First the account2 (test3) should fail config2 = tf.config.copy() config2['username'] = tf.config['username3'] diff --git a/test/functional/test_object.py b/test/functional/test_object.py index 768de19c05..324b506286 100644 --- a/test/functional/test_object.py +++ b/test/functional/test_object.py @@ -20,13 +20,14 @@ import json import unittest from uuid import uuid4 import time +from unittest import SkipTest from xml.dom import minidom import six from six.moves import range from test.functional import check_response, retry, requires_acls, \ - requires_policies, SkipTest, requires_bulk + requires_policies, requires_bulk import test.functional as tf from swift.common.utils import md5 @@ -941,7 +942,7 @@ class TestObject(unittest.TestCase): @requires_acls def test_read_only(self): if tf.skip3: - raise tf.SkipTest + raise SkipTest def get_listing(url, token, parsed, conn): conn.request('GET', '%s/%s' % (parsed.path, self.container), '', diff --git a/test/functional/test_object_versioning.py b/test/functional/test_object_versioning.py index 32eb092c82..4eb91f5f20 100644 --- a/test/functional/test_object_versioning.py +++ b/test/functional/test_object_versioning.py @@ -22,6 +22,7 @@ import six from copy import deepcopy from six.moves.urllib.parse import quote, unquote +from unittest import SkipTest import test.functional as tf @@ -31,7 +32,7 @@ from swift.common.middleware.versioned_writes.object_versioning import \ DELETE_MARKER_CONTENT_TYPE from test.functional.tests import Base, Base2, BaseEnv, Utils -from test.functional import cluster_info, SkipTest +from test.functional import cluster_info from test.functional.swift_test_client import Connection, \ ResponseError from test.functional.test_tempurl import TestContainerTempurlEnv, \ diff --git a/test/functional/test_slo.py b/test/functional/test_slo.py index 178e12680c..7ef6e484c5 100644 --- a/test/functional/test_slo.py +++ b/test/functional/test_slo.py @@ -19,6 +19,7 @@ import email.parser import itertools import json from copy import deepcopy +from unittest import SkipTest import six @@ -26,7 +27,7 @@ from swift.common.swob import normalize_etag from swift.common.utils import md5 import test.functional as tf -from test.functional import cluster_info, SkipTest +from test.functional import cluster_info from test.functional.tests import Utils, Base, Base2, BaseEnv from test.functional.swift_test_client import Connection, ResponseError diff --git a/test/functional/test_tempurl.py b/test/functional/test_tempurl.py index 6f442e4798..a7b4e84539 100644 --- a/test/functional/test_tempurl.py +++ b/test/functional/test_tempurl.py @@ -23,12 +23,13 @@ from copy import deepcopy import six from six.moves import urllib from time import time, strftime, gmtime +from unittest import SkipTest import test.functional as tf from swift.common.middleware import tempurl from test.functional import cluster_info from test.functional.tests import Utils, Base, Base2, BaseEnv -from test.functional import requires_acls, SkipTest +from test.functional import requires_acls from test.functional.swift_test_client import Account, Connection, \ ResponseError diff --git a/test/functional/test_versioned_writes.py b/test/functional/test_versioned_writes.py index 1dd381af90..30cb74c88a 100644 --- a/test/functional/test_versioned_writes.py +++ b/test/functional/test_versioned_writes.py @@ -20,12 +20,13 @@ import time import unittest import six from six.moves.urllib.parse import quote, unquote +from unittest import SkipTest import test.functional as tf from swift.common.utils import MD5_OF_EMPTY_STRING from test.functional.tests import Base, Base2, BaseEnv, Utils -from test.functional import cluster_info, SkipTest +from test.functional import cluster_info from test.functional.swift_test_client import Account, Connection, \ ResponseError diff --git a/test/unit/__init__.py b/test/unit/__init__.py index 51b3ff952c..6f731b70a4 100644 --- a/test/unit/__init__.py +++ b/test/unit/__init__.py @@ -64,11 +64,7 @@ import functools from gzip import GzipFile import mock as mocklib import inspect -import unittest - - -class SkipTest(unittest.SkipTest): - pass +from unittest import SkipTest EMPTY_ETAG = md5(usedforsecurity=False).hexdigest()