Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/development-workflow/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Prefer existing fixtures and integration classes; do not build a parallel mock f
| Agent skills | `just docs lint`; inspect links and walk through realistic workflow scenarios |
| Dependency, packaging, or CI configuration | Affected build/install checks and supported Python/dependency combinations from `pyproject.toml`, `uv.lock`, and CI |

The `tests/pyathena/` directory includes AWS integration tests despite the recipe's "unit tests" label.
The `tests/pyathena/` directory includes AWS integration tests; `just test offline` runs its tests that need no AWS without credentials, and `-m aws` with a path selects the AWS tests that a change affects.
Before a live AWS run or CI retry, inspect active Test workflows with `gh run list --workflow test.yaml` and check known local test runs.
Separate worktrees do not isolate AWS accounts, quotas, or shared test resources.
When runs overlap, serialize live validation and use targeted `-n 1` runs while iterating; complete the required suite coverage before Ready.
Expand Down
31 changes: 30 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,32 @@ jobs:
tool: just
- run: just lint

# The PyAthena tests that need no AWS, with no AWS credentials, on the newest
# Python version (the last of PYTHON_VERSIONS below).
offline:
runs-on: ubuntu-latest
# The AWS suites wait for this job.
timeout-minutes: 20
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
with:
python-version: '3.15'
enable-cache: true
# As in test-suite.yaml, uv's Python 3.13+ cannot compile Python.h.
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.15'
- uses: taiki-e/install-action@7a79fe8c3a13344501c80d99cae481c1c9085912 # v2.81.10
with:
tool: just
- run: just test offline

# Selects the AWS suites and Python versions. Draft and external-fork pull
# requests run none. A ready pull request runs the PyAthena suite only when
# the package, the tests, setup.cfg, the dependencies, or this workflow
Expand All @@ -73,7 +99,10 @@ jobs:
# and pyathena.aio, or the shared test fixtures change. Pull requests and the
# schedule test the newest Python version; a dispatch tests the requested
# versions or every version, and the Release workflow every version.
# The AWS suites wait for the offline checks, so a change that fails them
# does not run the AWS suites.
changes:
needs: [lint, offline]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round 1 (behavior and implementation; base 6acb688be38db78ffe6c6fe094281549e2c2cbf3, reviewed 3cc2a9db974e890c02969e36a6c30b63076fd640, repaired at 389c205bf26cc4e09c3755fc1f7a62ee264460bd). Covered: the _test-offline recipe and help, the offline job and the changes gate, the docs and agent guidance. Inputs: my own pass, /code-review high, /simplify.

FINDINGS (repaired): the AWS suites waited for offline but not for lint (/simplify altitude and efficiency); changes now needs both, at no cost, since lint finishes first. The job had no timeout although the AWS suites wait for it (/code-review); timeout-minutes: 20. CI on this Draft at 3cc2a9db: the offline job passed, 3941 tests in 48.7 s on 4 workers, 68 s in all.

Deferred with reasons: running the offline job on every supported Python version, or merging it into lint on 3.12 (#1495 specifies the newest version); the hard-coded 3.15 beside PYTHON_VERSIONS (expressions cannot take the last element of that JSON list; a comment ties them); the duplicated setup-uv/setup-python steps (the same as test-suite.yaml); -m aws in the AWS suite to skip the offline tests there (it would drop offline coverage on the other Python versions of the Release run); the 1-3 minutes the gate adds before the AWS suites (accepted to avoid AWS runs for changes that fail offline).

if: >-
github.event_name != 'pull_request' ||
(!github.event.pull_request.draft &&
Expand Down Expand Up @@ -139,7 +168,7 @@ jobs:
EVENT_NAME: ${{ github.event_name }}
REQUESTED_VERSIONS: ${{ inputs.python-versions }}
# Every supported version, oldest first; keep in sync with the
# pyproject.toml classifiers.
# pyproject.toml classifiers and the offline job's version.
PYTHON_VERSIONS: '["3.11", "3.12", "3.13", "3.14", "3.15"]'
run: |
case "$EVENT_NAME" in
Expand Down
5 changes: 4 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@ just lint # Python lint, format check, mypy, CloudFormation validation, and li

```bash
# ALWAYS run `just lint` first — tests will fail if lint doesn't pass
just test offline # PyAthena tests that need no AWS, with no AWS credentials or .env
just test pyathena # PyAthena tests, including AWS integration (runs lint first)
just test sqla # SQLAlchemy compliance suite
just test sqla-async # SQLAlchemy async compliance suite
```

Tests require AWS environment variables. Use a `.env` file (gitignored):
Run `just test offline` first; it needs no AWS credentials, and the testing guide's [offline section](docs/testing.md#run-the-tests-that-need-no-aws) describes its guard. When a change affects a request to AWS or how a result from AWS is read, also run the affected `aws` tests (`-m aws` with a path) against AWS.

Tests that use AWS require AWS environment variables. Use a `.env` file (gitignored):

```bash
AWS_DEFAULT_REGION=<region>
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Changes affecting async dialects also require the relevant tests under `tests/py
The PyAthena dialect tests are included in `just test pyathena`; they are not run by the two compliance-suite commands.
Exercise the regression on the version before the fix where practical, and record the before/after result.
Documentation-only changes need documentation checks; changes limited to logic independent of AWS need appropriate tests for that logic.
Check the testing guide before assuming that selecting a unit test avoids AWS setup.
`just test offline` runs the tests that need no AWS without AWS credentials; the testing guide describes when a change also needs the AWS tests.

External-fork pull requests must not be run in the project's AWS integration CI.
Do not submit an untested change expecting a maintainer to approve an AWS CI run to validate it.
Expand Down
45 changes: 23 additions & 22 deletions docs/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ uv run --env-file .env just test sqla
uv run --env-file .env just test sqla-async
```

Despite the recipe's "unit tests" label, `just test pyathena` includes AWS integration tests.
The recipes use eight pytest workers, so check your account's Athena concurrency quotas.
`just test pyathena` includes the AWS integration tests; `just test offline`, described below, runs only the tests that need no AWS.
The recipes that use AWS run eight pytest workers, so check your account's Athena concurrency quotas.
They also rerun a failed test once when its failure message is an Athena internal error or `Invalid S3 request`, and report the first attempt's traceback.
A failure of the session setup fails each test that uses AWS and is not tried again; a direct `pytest` invocation does not rerun.
Do not overlap test runs that share AWS resources or quota.
Expand All @@ -134,33 +134,33 @@ A targeted run helps during development but does not replace other coverage requ

(testing-offline)=

### Run self-contained tests offline
### Run the tests that need no AWS

The pandas and Polars result-set modules have self-contained tests that can run without AWS access.
Reuse the `.env` file described in the AWS environment section if it is already configured.
For an offline-only setup, create a gitignored `.env` file in the repository root with these placeholder values:
`just test offline` runs the tests under `tests/pyathena/` that carry no `aws` mark, without AWS credentials or a `.env` file:

```ini
AWS_DEFAULT_REGION=us-east-1
AWS_ATHENA_S3_STAGING_DIR=s3://pyathena-offline-placeholder/
AWS_ATHENA_WORKGROUP=offline
AWS_ATHENA_SPARK_WORKGROUP=offline
AWS_EC2_METADATA_DISABLED=true
```bash
just lint
just test offline
```

After `just lint`, load `.env` and run:
The recipe first syncs the environment as `uv run` does.
It then unsets every `AWS_*` and `FSSPEC_*` variable, including those of a loaded `.env` file, and `HTTP_PROXY`, `HTTPS_PROXY`, and `ALL_PROXY` in upper and lower case, sets `NO_PROXY` and `no_proxy` to `*`, keeps uv from loading a `.env` file, and sets:

- placeholder values for the four settings that `tests/__init__.py` requires;
- placeholder credentials that no AWS account accepts, empty AWS, boto, and fsspec configuration, and `AWS_EC2_METADATA_DISABLED=true`, so that no request made by accident is authorized;
- `AWS_ENDPOINT_URL=https://offline.invalid`, a reserved name that does not resolve, with `AWS_MAX_ATTEMPTS=1` and `POLARS_CLOUD_MAX_RETRIES=0`, so that a request that boto3 or Polars makes by accident fails at once without reaching AWS.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (relayed): Codex CLI (codex exec -s read-only, session 01a22665-425e-74b1-91c0-bf1099100a36; a first run was cut off by a session restart and is discarded), static review of 6acb688be38db78ffe6c6fe094281549e2c2cbf3..389c205bf26cc4e09c3755fc1f7a62ee264460bd in a detached snapshot with a neutral prompt; no edits, builds, or tests. Covered: fixture-derived marks, import-time settings, credential providers, filesystem clients, proxies, retries, bash 3.2 behavior, --no-env-file against UV_ENV_FILE, the job's permissions and needs semantics for pull_request, schedule, dispatch and workflow_call, concurrency, and the docs. Result: FINDINGS (8). Repairs at d6c05189a6851c1c342b20c61c25cf2ce92fb464.

  1. Documentation-only pull requests never start the offline job: not changed; the Test workflow's paths-ignore for docs/** and Markdown is the existing policy, and such changes need no tests. The guide states which pull requests the workflow runs for.

Validation at d6c05189: just lint, shellcheck, rumdl; just test offline 3941 passed; with FSSPEC_S3_KEY, FSSPEC_S3_ENDPOINT_URL, UV_ENV_FILE=.env and .env loaded, 3941 passed; under unshare -rn with UV_OFFLINE=1, 3938 passed, 3 skipped.

The `S3FileSystem` that PyAthena creates for PyArrow does not read `AWS_ENDPOINT_URL`; its requests reach AWS and are rejected for the placeholder credentials.

The recipe also runs without the rerun plugin, whose reruns cover only service-side errors of Athena and S3.
A test that reaches AWS in `just test offline` gets a connection error or a rejected request; make it request `aws_test_schema`, as described above, which also gives it the `aws` mark.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review round 1 (behavior and implementation; base 6acb688be38db78ffe6c6fe094281549e2c2cbf3, reviewed 3cc2a9db974e890c02969e36a6c30b63076fd640, repaired at 389c205bf26cc4e09c3755fc1f7a62ee264460bd). Covered: the _test-offline recipe and help, the offline job and the changes gate, the docs and agent guidance. Inputs: my own pass, /code-review high, /simplify.

FINDINGS (repaired): the guide told a contributor to give a test that reaches AWS the aws mark, which would deselect it without the session setup; it now says to request aws_test_schema (/code-review). The guide claimed that AWS_MAX_ATTEMPTS makes Polars fail at once; object_store does not read it, and the guide now states its retries (/code-review). AGENTS.md's "cannot be authorized by an account" was unclear; it links to this section instead (/simplify).

Deferred: shortening the list of what the recipe sets (/simplify); it states the guarantee a reader relies on. Keeping AWS_SHARED_CREDENTIALS_FILE=/dev/null and AWS_EC2_METADATA_DISABLED=true although environment credentials come first: some tests delete the credential variables and would then fall back to those sources.


The offline target covers a change whose behavior these tests exercise without AWS, such as parameter formatting, SQL compilation, the conversion of result files, or filesystem logic checked with stubbed responses.
When a change affects a request to AWS, or how PyAthena reads what AWS returns, also run the affected `aws` tests against your AWS environment, for example:

```bash
uv run --env-file .env pytest --noconftest -p no:rerunfailures -q \
tests/pyathena/pandas/test_result_set.py \
tests/pyathena/polars/test_result_set.py
uv run --env-file .env pytest -n 1 -m aws tests/pyathena/test_cursor.py
```

The four AWS configuration values are required by `tests/__init__.py`, which pytest still imports with `--noconftest`.
The offline-only `.env` example disables EC2 metadata to prevent implicit credential lookup through that service.
`--noconftest` excludes the conftest fixtures, including the AWS session setup; disabling the rerun plugin also avoids its local socket setup in restricted environments.
Use this invocation only for self-contained modules; integration tests need their normal fixtures and a real AWS environment.

### S3 null-version moves

The null-version move regression tests create three dedicated temporary buckets:
Expand Down Expand Up @@ -270,7 +270,8 @@ Retain dtype and schema checks, option contexts, and resource cleanup where appl
## GitHub Actions

The Test workflow runs for pull requests that change files other than `docs/` and Markdown.
It runs the offline checks (`just lint`) on each of them, including Drafts and external forks, and runs the AWS suites as follows:
It runs the offline checks (`just lint`, and `just test offline` on the newest supported Python version) on each of them, including Drafts and external forks.
The AWS suites start only after the offline checks pass, and run as follows:

| Trigger | PyAthena suite | SQLAlchemy tests | Spark tests | Python versions |
| --- | --- | --- | --- | --- |
Expand Down
29 changes: 27 additions & 2 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,46 @@ lint: license-headers
license-headers:
uv run python scripts/check_license_headers.py

# Run tests: just test (pyathena|sqla|sqla-async)
# Run tests: just test (pyathena|offline|sqla|sqla-async)
test target="help":
@just _test-{{ if target =~ "^-" { "help" } else { target } }}

_test-help:
@echo "Usage: just test <target>"
@echo ""
@echo "Targets:"
@echo " pyathena Run unit tests (runs lint first)"
@echo " pyathena Run the PyAthena tests, including AWS integration tests (runs lint first)"
@echo " offline Run the PyAthena tests that need no AWS, with no AWS credentials"
@echo " sqla Run SQLAlchemy dialect tests"
@echo " sqla-async Run SQLAlchemy async dialect tests"

_test-pyathena: lint
uv run pytest -n 8 {{PYTEST_RERUN}} --cov pyathena --cov-report html --cov-report term tests/pyathena/

# Sync the environment first, as uv run does, with the developer's settings.
# Then unset every AWS and fsspec setting and HTTP_PROXY, HTTPS_PROXY, and
# ALL_PROXY in either case, set NO_PROXY and no_proxy to '*', and give the four
# settings that tests/__init__.py requires placeholder values. A request
# made by accident carries credentials that no account accepts, and the clients
# that read AWS_ENDPOINT_URL send it to a reserved name that does not resolve
# (RFC 6761), with AWS_MAX_ATTEMPTS=1 and POLARS_CLOUD_MAX_RETRIES=0. uv must not
# load a .env file back.
_test-offline:
#!/usr/bin/env bash
set -euo pipefail
uv run --no-env-file true
for name in $(compgen -e AWS_) $(compgen -e FSSPEC_); do unset "$name"; done

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (relayed): Codex CLI (codex exec -s read-only, session 01a22665-425e-74b1-91c0-bf1099100a36; a first run was cut off by a session restart and is discarded), static review of 6acb688be38db78ffe6c6fe094281549e2c2cbf3..389c205bf26cc4e09c3755fc1f7a62ee264460bd in a detached snapshot with a neutral prompt; no edits, builds, or tests. Covered: fixture-derived marks, import-time settings, credential providers, filesystem clients, proxies, retries, bash 3.2 behavior, --no-env-file against UV_ENV_FILE, the job's permissions and needs semantics for pull_request, schedule, dispatch and workflow_call, concurrency, and the docs. Result: FINDINGS (8). Repairs at d6c05189a6851c1c342b20c61c25cf2ce92fb464.

  1. fsspec can supply live credentials and an endpoint (FSSPEC_S3_*, fsspec config files): repaired. Reproduced first: with FSSPEC_S3_KEY set, the four test_get_client_compatible_with_s3fs_profile cases fail, because fsspec applies its configuration in the filesystem metaclass (fsspec/spec.py:93). The recipe unsets FSSPEC_* and sets FSSPEC_CONFIG_DIR=/dev/null (not a directory, so no files are read); with the variable set, just test offline passes.
  2. isolated_aws_config exposes the legacy boto configuration (BOTO_CONFIG, ~/.boto): repaired in the recipe (BOTO_CONFIG=/dev/null) and the fixture.
  3. An anonymous PyArrow filesystem can read a public object: not changed; the guard is the environment-variable layer agreed on Run tests locally without AWS charges #1461, and an unsigned read bills the bucket owner, not the developer's account. Repaired the guide's PyArrow sentence: the S3FileSystem constructor that PyAthena uses does not read AWS_ENDPOINT_URL (the URI factory does).
  4. Polars retries an accidental request: repaired with POLARS_CLOUD_MAX_RETRIES=0; measured 28.9 s → 0.37 s.
  5. and 7. The no_proxy merge loses exclusions; uv's automatic sync runs in the cleared environment: repaired together: the recipe runs uv sync --inexact first with the developer's settings, then unsets the proxy variables (no NO_PROXY merge any more) and runs uv run --no-sync --no-env-file. A probe of the pytest process with FSSPEC_S3_KEY, HTTPS_PROXY, UV_ENV_FILE=.env and .env loaded shows only the recipe's settings.
  6. An inherited PYTEST_ADDOPTS can turn the run into a collection: not changed; it is the developer's own pytest setting, and CI's offline job sets none.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repair self-review, round 1 perspective (389c205b..d6c05189). Checked: compgen -e FSSPEC_ with no such variable and set -u; unset of proxy variables that are not set; uv sync --inexact matches what uv run syncs (the default groups include dev) and keeps packages that uv run would keep; uv run --no-sync cannot sync with the cleared settings; FSSPEC_CONFIG_DIR=/dev/null is skipped by fsspec.config.set_conf_files (os.path.isdir); the fixture's BOTO_CONFIG points at a missing file in tmp_path. CI's offline job has no proxy and a cold cache syncs in the first step. CLEAN.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repair self-review, round 2 perspective (389c205b..d6c05189). Claims checked: the recipe comment and the guide's list match the recipe line by line; "fails at once" now holds for boto3 (0.13 s) and Polars (0.37 s); the PyArrow sentence is limited to the constructor that PyAthena uses; the fixture docstring names the boto file. The PR body is updated. CLEAN.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up (relayed): Codex CLI (codex exec -s read-only, session 01a22676-1914-7911-ad13-65c1ce82f799), static review of 389c205b..d6c05189. Findings 1, 2, 3, 5, 6 and 7 of the first review resolved for their scenarios. New FINDINGS (4), all repaired in 3518bf73:

  1. Without proxy variables, Python's getproxies() falls back to the macOS system proxy, and a mixed-case Https_Proxy survived the unset: the recipe sets NO_PROXY='*' and no_proxy='*'.
  2. Outside the recipe, fsspec has already loaded FSSPEC_S3_* at import, so isolated_aws_config did not isolate the fsspec settings: the fixture replaces fsspec.config.conf for its lifetime (apply_config reads the module global at call time). With FSSPEC_S3_KEY set and no recipe, the isolated tests pass (21 selected).
  3. uv sync --inexact ignored UV_NO_SYNC: the recipe syncs with uv run --no-env-file true, which follows uv's own rules; UV_NO_SYNC=1 just test offline passes.
  4. The recipe comment promised one attempt for Polars: it now says "without retries".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repair self-review, both perspectives (d6c05189..3518bf73). Behavior: NO_PROXY=* makes urllib.request.getproxies() return only the no entry and proxy_bypass_environment bypass every host; uv run --no-env-file true syncs exactly as the later uv run --no-sync would have; the fixture's monkeypatch.setattr restores fsspec.config.conf after each test. Claims: the recipe comment, the fixture docstring, and the guide's "bypasses every proxy" match the code. Validation at 3518bf73: just lint, shellcheck, rumdl; just test offline 3941 passed with UV_NO_SYNC=1; under unshare -rn with .env, UV_ENV_FILE and UV_OFFLINE=1, 3938 passed, 3 skipped. CLEAN.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up 2 (relayed): Codex CLI (codex exec -s read-only, session 01a227c7-9f84-79d2-836c-ddcb4ce51230; an earlier run was stopped by the host for low memory and is discarded), static review of d6c05189..3518bf73. All four findings of follow-up 1 resolved (botocore's macOS fallback and mixed-case proxies bypassed for offline.invalid; the fixture's fsspec isolation; uv run ... true honors UV_FROZEN, UV_LOCKED and UV_NO_SYNC). New FINDINGS (3):

  1. With UV_ISOLATED=1, the first uv run installs into a temporary environment and the second skips installation: not changed; isolated mode with a project command is unusual, and wrapping the whole recipe in one uv run would move the cleanup into a separate script.
  2. "Bypasses every proxy" overstates it (Polars' reqwest matches * against domain names, not literal IPs): repaired in ae20c6c2; the guide and the recipe comment name NO_PROXY='*' instead.
  3. "Without retries" overstates it (Polars can rebuild the store and repeat a range read): repaired; the comment names AWS_MAX_ATTEMPTS=1 and POLARS_CLOUD_MAX_RETRIES=0.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Repair self-review, both perspectives (3518bf73..ae20c6c2, comment and docs wording only): the recipe comment and the guide now name the settings the recipe exports, line for line; no code changed, so the validation at 3518bf73 stands. CLEAN.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up 3 (relayed): Codex CLI (session 01a227d1-3095-7cb1-884d-a2f8af2c64c2), static review of 3518bf73..ae20c6c2. The retry wording is accurate. FINDINGS (1, wording): "unset every ... proxy setting" overstated it, since a mixed-case name such as Https_Proxy survives the unset (and is bypassed by NO_PROXY='*'). Repaired in 0abd0d03: both texts list HTTP_PROXY, HTTPS_PROXY and ALL_PROXY in upper and lower case and NO_PROXY/no_proxy. Repair self-review (both perspectives): wording only, matches the recipe line for line; CLEAN.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent follow-up 4 (relayed): Codex CLI (session 01a227d2-fb51-70a1-8045-0e90ff388d0a), static review of ae20c6c2..0abd0d03: CLEAN.

unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy
export NO_PROXY='*' no_proxy='*'
export AWS_DEFAULT_REGION=us-west-2
export AWS_ATHENA_S3_STAGING_DIR=s3://pyathena-offline-placeholder/
export AWS_ATHENA_WORKGROUP=offline AWS_ATHENA_SPARK_WORKGROUP=offline
export AWS_ACCESS_KEY_ID=offline AWS_SECRET_ACCESS_KEY=offline
export AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null BOTO_CONFIG=/dev/null
export AWS_EC2_METADATA_DISABLED=true FSSPEC_CONFIG_DIR=/dev/null
export AWS_ENDPOINT_URL=https://offline.invalid AWS_MAX_ATTEMPTS=1 POLARS_CLOUD_MAX_RETRIES=0
uv run --no-sync --no-env-file pytest -n auto -p no:rerunfailures -m "not aws" tests/pyathena/

_test-sqla:
uv run pytest -n 8 {{PYTEST_RERUN}} --cov pyathena --cov-report html --cov-report term tests/sqlalchemy/

Expand Down
10 changes: 7 additions & 3 deletions tests/pyathena/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import uuid

import boto3
import fsspec.config
import pytest
import sqlalchemy
from sqlalchemy.ext.asyncio import create_async_engine as _create_async_engine
Expand Down Expand Up @@ -477,9 +478,10 @@ def isolated_aws_config(monkeypatch, tmp_path):
"""Hide the AWS environment variables and config files of the environment.

A test that builds clients with this fixture gets the settings it passes,
not those of the developer or of the offline test target. The EC2 instance
metadata service stays disabled, so a client built without credentials
does not look for them there.
not those of the developer or of the offline test target. The legacy boto
configuration file and the fsspec configuration loaded at import are
hidden too, and the EC2 instance metadata service stays disabled, so a
client built without credentials does not find any.

Args:
monkeypatch: The pytest monkeypatch fixture.
Expand All @@ -490,6 +492,8 @@ def isolated_aws_config(monkeypatch, tmp_path):
monkeypatch.delenv(key)
monkeypatch.setenv("AWS_CONFIG_FILE", str(tmp_path / "config"))
monkeypatch.setenv("AWS_SHARED_CREDENTIALS_FILE", str(tmp_path / "credentials"))
monkeypatch.setenv("BOTO_CONFIG", str(tmp_path / "boto"))
monkeypatch.setattr(fsspec.config, "conf", {})
monkeypatch.setenv("AWS_EC2_METADATA_DISABLED", "true")


Expand Down
Loading