Skip to content

Run the shadowed test_strip_relative_path and fix its expectations - #4120

Open
dylanpulver wants to merge 1 commit into
plotly:devfrom
dylanpulver:unshadow-strip-relative-path-test
Open

dylanpulver wants to merge 1 commit into
plotly:devfrom
dylanpulver:unshadow-strip-relative-path-test

Conversation

@dylanpulver

Copy link
Copy Markdown

Targets dev as a fix.

tests/unit/test_configs.py defines test_strip_relative_path twice, at line 175 and line 296. The second replaces the first, so the test at 175 has never run.

They are different tests. The one at 175 is the twin of the live test_get_relative_path above it, checking that app.strip_relative_path and the module level strip_relative_path agree with each other and with the expected value. The one at 296 exercises app_strip_relative_path. So this renames the second to test_app_strip_relative_path, after the function it calls and matching test_invalid_strip_relative_path beside it.

The rename alone leaves the revived test failing. Both its expected values carry a leading slash that strip_relative_path does not produce. With prefix=None both calls return app/page2, and with prefix='/app/' both return page2. The live test expects no leading slash anywhere, for example ("/", "/page-1/sub-page-1", "page-1/sub-page-1"), so these two values were wrong when written and being shadowed from the start hid it. Corrected to app/page2 and page2.

On why this survived: pylint does report E0102 function already defined line 175, but private::lint.pylint-tests runs -d all -e C0410,C0413,W0109, so E0102 is not enabled for tests/. With it enabled this file goes from 1 to 0.

Verified in a venv on dash 4.5.0, filtering to these tests. Before: 22 collected, 22 passed. Rename only: 24 collected, 2 failed. Both changes: 24 collected, 24 passed. Reverting just the rename returns collection to 22, and corrupting a corrected value fails the test, so both halves carry weight. black --check and flake8 are clean, and private::lint.pylint-tests rates the file 10.00/10.

test_configs.py defines test_strip_relative_path twice, at line 175 and
296, so the first has never run. The two test different functions, so
this renames the second to test_app_strip_relative_path after the
function it calls.

The revived test then fails: both its expected values carry a leading
slash that strip_relative_path does not produce. The live test beside it
expects no leading slash anywhere, so these were wrong when written and
being shadowed hid it.
@sonarqubecloud

sonarqubecloud Bot commented Nov 5, 2026

Copy link
Copy Markdown

@KoolADE85

Copy link
Copy Markdown
Contributor

Hey @dylanpulver , we're not sure what issue you're encountering that you want this PR to solve. Please open an issue before submitting a PR here. Thanks!

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