-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
test: cover POSIX file URI root preservation #8906
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -446,6 +446,12 @@ def test_file_uri_to_path_supports_standard_and_legacy_posix_file_uris(tmp_path) | |||||||||||||||||||||||||||||||||||||
| assert media_utils.file_uri_to_path(legacy_file_uri) == str(media_path) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def test_file_uri_to_path_preserves_posix_root_for_container_paths(): | ||||||||||||||||||||||||||||||||||||||
| assert media_utils.file_uri_to_path("file:///AstrBot/data/cache/image.png") == ( | ||||||||||||||||||||||||||||||||||||||
| "/AstrBot/data/cache/image.png" | ||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+449
to
+452
Contributor
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. suggestion (testing): Add coverage for the bare root and directory-only POSIX file URIs, not just a full file path. To strengthen the root-preservation guarantee, please extend this test (via parametrization or additional asserts) to also cover:
This will ensure minimal and directory-only URIs keep their leading slash as expected.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| def test_from_file_system_uses_pathlib_file_uri(tmp_path): | ||||||||||||||||||||||||||||||||||||||
| media_path = tmp_path / "media file.bin" | ||||||||||||||||||||||||||||||||||||||
| media_path.write_bytes(b"media") | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test asserts a hardcoded POSIX-style path (
/AstrBot/data/cache/image.png), which will fail on Windows becausefile_uri_to_pathnormalizes paths using platform-specific separators (backslashes on Windows). Since this test is specifically designed to verify POSIX absolute file URI root preservation, it should be guarded withif os.name != 'nt':to ensure cross-platform compatibility, consistent with other tests in this file.