-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
CI for boto: fix errors; add coverage; add skip for uncatchable ResourceWarning #23731
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
5c5c5fa 488d767 186b215 7682581 5979389 5ce301d 49ff454 0b58728 eb1f65b ae0821d abb5d6a f660e40 b532696 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -4,6 +4,7 @@ channels: | |
| - conda-forge | ||
| dependencies: | ||
| - beautifulsoup4 | ||
| - botocore>=1.11 | ||
| - cython>=0.28.2 | ||
| - dask | ||
| - fastparquet | ||
| | @@ -35,10 +36,10 @@ dependencies: | |
| - pytest | ||
| - pytest-xdist | ||
| - pytest-cov | ||
| - moto | ||
| - hypothesis>=3.58.0 | ||
| - pip: | ||
| - brotlipy | ||
| - coverage | ||
| - moto | ||
| Contributor Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. conda pulls in moto 1.1.1, which is way too old. | ||
| - pandas-datareader | ||
| - python-dateutil | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,10 @@ | ||
| from distutils.version import LooseVersion | ||
| import os | ||
| | ||
| import pytest | ||
| | ||
| import pandas.util.testing as tm | ||
| | ||
| from pandas.io.parsers import read_csv | ||
| | ||
| | ||
| | @@ -37,43 +43,48 @@ def s3_resource(tips_file, jsonl_file): | |
| """ | ||
| pytest.importorskip('s3fs') | ||
| boto3 = pytest.importorskip('boto3') | ||
| # 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 = [ | ||
| ('tips.csv', tips_file), | ||
| ('tips.csv.gz', tips_file + '.gz'), | ||
| ('tips.csv.bz2', tips_file + '.bz2'), | ||
| ('items.jsonl', jsonl_file), | ||
| ] | ||
| | ||
| def add_tips_files(bucket_name): | ||
| for s3_key, file_name in test_s3_files: | ||
| with open(file_name, 'rb') as f: | ||
| conn.Bucket(bucket_name).put_object( | ||
| Key=s3_key, | ||
| Body=f) | ||
| | ||
| try: | ||
| | ||
| s3 = moto.mock_s3() | ||
| s3.start() | ||
| | ||
| # see gh-16135 | ||
| bucket = 'pandas-test' | ||
| conn = boto3.resource("s3", region_name="us-east-1") | ||
| | ||
| conn.create_bucket(Bucket=bucket) | ||
| add_tips_files(bucket) | ||
| | ||
| conn.create_bucket(Bucket='cant_get_it', ACL='private') | ||
| add_tips_files('cant_get_it') | ||
| yield conn | ||
| except: # noqa: flake8 | ||
| pytest.skip("failure to use s3 resource") | ||
| finally: | ||
| s3.stop() | ||
| 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") | ||
| Contributor Author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually this skip is needed because | ||
| | ||
| with tm.ensure_safe_environment_variables(): | ||
| # 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") | ||
| | ||
| moto = pytest.importorskip('moto') | ||
| | ||
| test_s3_files = [ | ||
| ('tips.csv', tips_file), | ||
| ('tips.csv.gz', tips_file + '.gz'), | ||
| ('tips.csv.bz2', tips_file + '.bz2'), | ||
| ('items.jsonl', jsonl_file), | ||
| ] | ||
| | ||
| def add_tips_files(bucket_name): | ||
| for s3_key, file_name in test_s3_files: | ||
| with open(file_name, 'rb') as f: | ||
| conn.Bucket(bucket_name).put_object( | ||
| Key=s3_key, | ||
| Body=f) | ||
| | ||
| try: | ||
| s3 = moto.mock_s3() | ||
| s3.start() | ||
| | ||
| # see gh-16135 | ||
| bucket = 'pandas-test' | ||
| conn = boto3.resource("s3", region_name="us-east-1") | ||
| | ||
| conn.create_bucket(Bucket=bucket) | ||
| add_tips_files(bucket) | ||
| | ||
| conn.create_bucket(Bucket='cant_get_it', ACL='private') | ||
| add_tips_files('cant_get_it') | ||
| yield conn | ||
| finally: | ||
| s3.stop() | ||
Uh oh!
There was an error while loading. Please reload this page.