Skip to content

test(unit): fix cross_account pollution + standardize unit-test setup#12

Merged
chanshih merged 1 commit into
mainfrom
fix/lambda-runtime-test-isolation
Jul 21, 2026
Merged

test(unit): fix cross_account pollution + standardize unit-test setup#12
chanshih merged 1 commit into
mainfrom
fix/lambda-runtime-test-isolation

Conversation

@karanjhaveri

Copy link
Copy Markdown
Contributor

Fixes the sys.modules pollution introduced in PR #9: test_lambda_runtime_tool.py replaced shared.cross_account in sys.modules at module scope and never restored it, breaking all of test_cross_account.py in a full make test-unit run.

  • Replace the global stub with a scoped cross_account_stub fixture (monkeypatch.setitem, auto-restored).
  • Add tests/unit/conftest.py: centralizes deterministic AWS test env (region + dummy creds at import) and auto-applies the unit
    marker to the whole package, so pytest -m unit selects all of it.
  • Drop now-redundant per-file AWS_REGION setdefaults + the lone pytestmark.
  • docs/development.md: add a "Testing Conventions" section.

488 unit + topology tests pass.

test_lambda_runtime_tool.py replaced shared.cross_account in sys.modules at
module scope and never restored it, breaking all of test_cross_account.py in a
full `make test-unit` run. Replace with a scoped `cross_account_stub` fixture
(monkeypatch.setitem, auto-restored).

Also standardize the unit suite so this class of drift is less likely:
- add tests/unit/conftest.py: centralizes deterministic AWS test env (region +
  dummy creds at import time) and auto-applies the `unit` marker to the whole
  package, so `pytest -m unit` selects all of it.
- drop now-redundant per-file AWS_REGION setdefaults + the lone pytestmark.
- docs/development.md: add a "Testing Conventions" section codifying handler
  loading, the no-global-sys.modules-stub rule, env handling, moto-vs-MagicMock,
  and markers.

488 unit+topology tests pass.
@karanjhaveri
karanjhaveri requested a review from chanshih July 21, 2026 03:50
@chanshih
chanshih merged commit a78cbf5 into main Jul 21, 2026
3 checks passed
@chanshih
chanshih deleted the fix/lambda-runtime-test-isolation branch July 21, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants