pytest: add global configfile and autouse teardown fixtures

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 672a123348)
This commit is contained in:
Casey Bodley 2023-01-20 14:44:08 -05:00 committed by Ali Maredia
parent d528efdda9
commit c749452fd0
10 changed files with 37 additions and 0 deletions

View file

@ -7,6 +7,7 @@ import itertools
import os import os
import random import random
import string import string
import pytest
from http.client import HTTPConnection, HTTPSConnection from http.client import HTTPConnection, HTTPSConnection
from urllib.parse import urlparse from urllib.parse import urlparse
@ -370,6 +371,15 @@ def teardown():
# remove our buckets here also, to avoid littering # remove our buckets here also, to avoid littering
nuke_prefixed_buckets(prefix=prefix) nuke_prefixed_buckets(prefix=prefix)
@pytest.fixture(scope="package")
def configfile():
setup()
yield config
@pytest.fixture(autouse=True)
def setup_teardown(configfile):
yield
teardown()
bucket_counter = itertools.count(1) bucket_counter = itertools.count(1)

View file

@ -27,6 +27,8 @@ from .utils import assert_raises
from email.header import decode_header from email.header import decode_header
from . import ( from . import (
configfile,
setup_teardown,
_make_raw_request, _make_raw_request,
nuke_prefixed_buckets, nuke_prefixed_buckets,
get_new_bucket, get_new_bucket,

View file

@ -37,6 +37,8 @@ from .utils import assert_raises
from .policy import Policy, Statement, make_json_policy from .policy import Policy, Statement, make_json_policy
from . import ( from . import (
configfile,
setup_teardown,
nuke_prefixed_buckets, nuke_prefixed_buckets,
get_new_bucket, get_new_bucket,
get_new_bucket_name, get_new_bucket_name,

View file

@ -19,6 +19,8 @@ from nose.plugins.skip import SkipTest
from .. import common from .. import common
from . import ( from . import (
configfile,
setup_teardown,
get_new_bucket, get_new_bucket,
get_new_bucket_name, get_new_bucket_name,
s3, s3,

View file

@ -1,3 +1,4 @@
import pytest
import boto3 import boto3
from botocore import UNSIGNED from botocore import UNSIGNED
from botocore.client import Config from botocore.client import Config
@ -308,6 +309,16 @@ def teardown():
except: except:
pass pass
@pytest.fixture(scope="package")
def configfile():
setup()
return config
@pytest.fixture(autouse=True)
def setup_teardown(configfile):
yield
teardown()
def check_webidentity(): def check_webidentity():
cfg = configparser.RawConfigParser() cfg = configparser.RawConfigParser()
try: try:

View file

@ -10,6 +10,8 @@ from .utils import _get_status_and_error_code
from .utils import _get_status from .utils import _get_status
from . import ( from . import (
configfile,
setup_teardown,
get_client, get_client,
get_v2_client, get_v2_client,
get_new_bucket, get_new_bucket,

View file

@ -7,6 +7,8 @@ from nose.tools import eq_ as eq
from s3tests_boto3.functional.utils import assert_raises from s3tests_boto3.functional.utils import assert_raises
from s3tests_boto3.functional.test_s3 import _multipart_upload from s3tests_boto3.functional.test_s3 import _multipart_upload
from . import ( from . import (
configfile,
setup_teardown,
get_alt_client, get_alt_client,
get_iam_client, get_iam_client,
get_new_bucket, get_new_bucket,

View file

@ -41,6 +41,8 @@ from .utils import _get_status
from .policy import Policy, Statement, make_json_policy from .policy import Policy, Statement, make_json_policy
from . import ( from . import (
configfile,
setup_teardown,
get_client, get_client,
get_prefix, get_prefix,
get_unauthenticated_client, get_unauthenticated_client,

View file

@ -9,6 +9,8 @@ import uuid
from nose.tools import eq_ as eq from nose.tools import eq_ as eq
from . import ( from . import (
configfile,
setup_teardown,
get_client get_client
) )

View file

@ -32,6 +32,8 @@ from collections import namedtuple
from email.header import decode_header from email.header import decode_header
from . import( from . import(
configfile,
setup_teardown,
get_iam_client, get_iam_client,
get_sts_client, get_sts_client,
get_client, get_client,