From 7682581dfd2fb2510c78d1906f0eb3a538d7ee09 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Fri, 7 Dec 2018 17:37:38 +0100 Subject: [PATCH] Skip old botocore; don't skip on moto; undo env vars in finally --- pandas/tests/io/conftest.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pandas/tests/io/conftest.py b/pandas/tests/io/conftest.py index 21184a16cc0c4..fca37b75912cb 100644 --- a/pandas/tests/io/conftest.py +++ b/pandas/tests/io/conftest.py @@ -1,3 +1,4 @@ +from distutils.version import LooseVersion import os import pytest @@ -40,17 +41,18 @@ def s3_resource(tips_file, jsonl_file): """ pytest.importorskip('s3fs') boto3 = pytest.importorskip('boto3') + botocore = pytest.importorskip('botocore') + + if LooseVersion(botocore.__version__) < LooseVersion("1.11.0"): + # botocore leaks an uncatchable ResourceWarning before 1.11.0; + # see GH 23731 and https://github.com/boto/botocore/issues/1464 + pytest.skip("botocore is leaking resources before 1.11.0") # temporary workaround as moto fails for botocore >= 1.11 otherwise # see https://github.com/spulec/moto/issues/1924 & 1952 os.environ.setdefault("AWS_ACCESS_KEY_ID", "foobar_key") os.environ.setdefault("AWS_SECRET_ACCESS_KEY", "foobar_secret") - # GH-24092. See if boto.plugin skips the test or fails. - try: - pytest.importorskip("boto.plugin") - except AttributeError: - raise pytest.skip("moto/moto error") moto = pytest.importorskip('moto') test_s3_files = [ @@ -83,3 +85,5 @@ def add_tips_files(bucket_name): yield conn finally: s3.stop() + os.environ.setdefault("AWS_ACCESS_KEY_ID", None) + os.environ.setdefault("AWS_SECRET_ACCESS_KEY", None)