Skip to content

test(tensorboard): drop three duplicated copies of the presigned-URL test block - #6266

Open
Anai-Guo wants to merge 1 commit into
aws:masterfrom
Anai-Guo:test-tensorboard-drop-duplicated-blocks
Open

test(tensorboard): drop three duplicated copies of the presigned-URL test block#6266
Anai-Guo wants to merge 1 commit into
aws:masterfrom
Anai-Guo:test-tensorboard-drop-duplicated-blocks

Conversation

@Anai-Guo

Copy link
Copy Markdown

Issue

None (found by auditing duplicate top-level def names in the test suite).

Description

sagemaker-core/tests/unit/interactive_apps/test_tensorboard.py contains the same four-test block four times over, plus an older superseded copy of three of them. Because a later def silently rebinds an earlier one at module scope, only the last definition of each name is ever collected — so roughly 420 of the file's 840 lines are dead code:

test definitions live one
test_tb_presigned_url_invalid_params 4 byte-identical last
test_tb_presigned_url_failure 1 superseded + 4 byte-identical last
test_tb_invalid_presigned_kwargs 1 superseded + 4 byte-identical last
test_tb_valid_presigned_kwargs 1 superseded + 3 byte-identical + 1 truncated last (truncated)

Two details worth calling out:

  1. The three superseded definitions are the pre-rewrite originals. The newer versions patch BaseInteractiveApp.__init__ and build the tb_app fixture explicitly. The old test_tb_valid_presigned_kwargs is in fact broken — its trailing web-browser block dereferences a tb_app name it never binds (NameError), which is precisely the defect the rewrite fixed. Nothing is lost by removing them.

  2. The only copy that actually ran was the truncated one. The last test_tb_valid_presigned_kwargs drops the final assertions covering open_in_default_web_browser=True. Keeping the first complete copy instead restores that coverage, which is the sole behavioural effect of this PR.

This change keeps exactly one definition of each test and deletes the rest (+0 / −421).

Testing done

$ pytest sagemaker-core/tests/unit/interactive_apps/test_tensorboard.py
  • --collect-only: 11 tests before, 11 tests after (no test is added or removed — the duplicates were never collected).
  • Run: 10 passed / 1 failed before, 10 passed / 1 failed after, identical. The single failure is test_tb_init_with_default_region, a pre-existing environment dependency (it needs a default AWS region configured) and is unaffected by this change.
  • The restored open_in_default_web_browser=True assertions execute and pass.

Merge Checklist

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (existing tests; this PR restores dead ones)
  • I have checked that my tests are not configured for a specific region or account (this change removes duplicated tests only)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

🤖 Generated with Claude Code

…test block

`sagemaker-core/tests/unit/interactive_apps/test_tensorboard.py` contains the
same four-test block four times over, plus an older superseded copy of three of
them. Because a later `def` silently rebinds an earlier one at module scope,
only the last definition of each name is collected, so ~420 lines of the file
are dead:

* `test_tb_presigned_url_invalid_params` - 4 byte-identical definitions
* `test_tb_presigned_url_failure`        - 1 superseded + 4 byte-identical
* `test_tb_invalid_presigned_kwargs`     - 1 superseded + 4 byte-identical
* `test_tb_valid_presigned_kwargs`       - 1 superseded + 3 byte-identical
                                           + 1 truncated

The three superseded definitions are the pre-rewrite originals: the newer ones
patch `BaseInteractiveApp.__init__` and build the `tb_app` fixture explicitly.
The old `test_tb_valid_presigned_kwargs` is in fact broken - its trailing
web-browser block dereferences a `tb_app` name it never binds, which is exactly
the defect the rewrite fixed - so nothing is lost by removing it.

One behavioural detail matters: the *last* copy of
`test_tb_valid_presigned_kwargs` (the only one that was actually collected) is a
truncated version that drops the final assertions covering
`open_in_default_web_browser=True`. Keeping the first complete copy instead
restores that coverage.

This change keeps exactly one definition of each test and deletes the rest.

Verified with `pytest tests/unit/interactive_apps/test_tensorboard.py`: 11 tests
collected both before and after, and the same 10 pass / 1 pre-existing
environment failure (`test_tb_init_with_default_region`, which needs a default
AWS region) in both runs - with the restored web-browser assertions now
executing.

Signed-off-by: Anai-Guo <antai12232931@outlook.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant